sql in语句传参数
delete from table where id in (1,2,3,4,5)
请问那个1,2,3,4,5要怎样传进去啊?
========================
我现在是用循环。
delete from table where id = ?
但我想知道用In如何传参
------解决方案--------------------String ins="";
String[] ids="1,2,3,4,5".split(",");
for(String id : ids){
if(ins.equals("")){
ins="'"+id+"'";
} else{
ins=ins+","+"'"+id+"'";
}
}
String sql="delete from table where id in (?)";