首页 >后端开发 >php教程 >SQL语法急求解决方案

SQL语法急求解决方案

WBOY
WBOY原创
2016-06-13 10:26:09796浏览

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}') ...

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn