mysql in 加引号

场景:

访问地址:http://xxx.com/index.php?m=home&c=demo&a=test&keyword=3B9D082D,3B9D082A,3B9D0903,3B9D082C

把接收到参数(keyword),在sql查询中,使用in会自动加上引号

 

php应用代码:

$param = $this->param();
$keyword = $param['keyword'];
$sql = "SELECT * from mes_goods_warehouse_lists WHERE FIND_IN_SET(barcode,'{$keyword}')";
$res = Db::query($sql);
print_r($res);

 

原始sql代码:

SELECT * from mes_goods_warehouse_lists WHERE FIND_IN_SET(barcode,'3B9D082D,3B9D082A');
// 相当于下面代码
SELECT * from mes_goods_warehouse_lists WHERE barcode in('3B9D082D','3B0D082A')

 

上一篇:easypoi 省市县三级联动


下一篇:Data Matrix of Zint