Heim >Backend-Entwicklung >PHP-Tutorial >SQL语法急求解决方案
SQL语法急求
SELECT `id`,`linkurl` FROM `users` WHERE `id` NOT IN('143,137,137,153,88,3') AND `able`='yes' ORDER BY `jifen` DESC LIMIT 1这样写法对吗
怎么把变量
$value=143,137,137,153,88,3';传入到
SELECT `id`,`linkurl` FROM `users` WHERE `id` NOT IN('$value') AND `able`='yes' ORDER BY `jifen` DESC LIMIT 1
------解决方案--------------------
若 id 是字符型的或一定要加单引号的话,$value 需加工一下
$value = '143,137,137,153,88,3';
$value = str_replace(',', "','", $value);
... `id` NOT IN('{$value}') ...