如何对单字段单列中用逗号分隔的多条记录执行搜索查询?

时间:2019-05-28 09:31:42

标签: php sql ajax

if(count($_POST["search"]) > 0) {

     $arrayString =  implode("','",$_POST["search"]) ;
}
//echo $arrayString;exit;

 $sql="SELECT * FROM domain_inventory_Global_History WHERE company_domain in ('$arrayString') ";
 echo $sql;

2 个答案:

答案 0 :(得分:0)

您可以使用LIKE运算符来处理。例如

 $sql="SELECT * FROM domain_inventory_Global_History WHERE company_domain LIKE %$arrayString%"

答案 1 :(得分:0)

$ searchStrings = ['google.com','yahoo','fa'];

$ sql =“ SELECT * FROM domain_inventory_Global_History WHERE where company_domain like%”。implode(“%or company_domain like%”,$ searchStrings)。“%”;

echo $ sql;