如何使用MYSQL IN Operator通过php数组获取多个记录

 $region_arr=array('Capital','ABC','Def');
 $RegionStr = implode(',', $region_arr);
 $sql="SELECT tax_id from bf_taxes where tax_region IN ('$RegionStr')";

This query is not working for me And when echoed it The result was

 SELECT tax_id from bf_taxes where tax_region IN ('Capital,ABC,DEF');

Which is wrong.The Query Should have been

 SELECT tax_id from bf_taxes where tax_region IN ('Capital','ABC','DEF');

Then the query would have given me the accurate result.So suggest me the changes i need to make in my code to achieve the desired result.

Try like this by preceding the quotes(') before and after the regions,

$region_arr=array('Capital','ABC','Def');
$RegionStr = "'".implode("','", $region_arr)."'"; //see this line
$sql="SELECT tax_id from bf_taxes where tax_region IN ($RegionStr);";
echo $sql;

Output:

SELECT tax_id from bf_taxes where tax_region IN ('Capital','ABC','Def');