当前位置: 代码迷 >> PHP >> SQL语法急求解决方案
  详细解决方案

SQL语法急求解决方案

热度:109   发布时间:2012-06-05 13:54:06.0
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}') ...
  相关解决方案