一个字符串是 '1,2,3,4'?
那么可以这样写sql
select * from tbname where position(concat(id) in '1,2,3,4')!=0
表示id 在 1,2,3,4里面
用 explode函数
$arr = explode(",","1,2,3,4");
foreach($arr as $key => $var){
echo $var."
";
}
输出
1
2
3
4
简单,用 explode函数
$arr = explode(",","1,2,3,4");
foreach($arr as $key => $var){
echo $var."
";
}
输出
1
2
3
4
select id from (1,2,3,4)这是不可以的,mysql没有这样的语法
select id from table where id in(1,2,3,4)