我现在有个数组array("1","2","3","4")
我想将数据库表中所有id符合以上数组中的值的那条数据中status的值改成“1”,现在只想用一条sql语句来实现,how to do it?
我现在有个数组array("1","2","3","4")
我想将数据库表中所有id符合以上数组中的值的那条数据中status的值改成“1”,现在只想用一条sql语句来实现,how to do it?
UPDATE #TABLE
SET STATUS=1
WHERe ID IN ("1","2","3","4")
update [tablename] set status = 1 where id=1 or id=2 or id=3 or id=4;
update [tablename] set status = 1 where id between 1 and 4
update [tablename] set status = 1 where id in (数组的值)
如果数据不是很多,估计只能使用for循环来实现插入。
update 表明 set 列名=要改的值 where id in(数组里存的值)