我正在尝试解决如何在1个事务中更新多个记录。
通常在MS SQL SERVER中,我会
Update table
set status 'YES' where ID in ('1', '2', '3', '4', '5', '6', etc)然而,在MYSQL中,我找不到正确的语法。
我是否可以使用小于、介于大于运算符?>= and <=?或者我可以像在上面的语句中一样使用where "ID" in ('','','','')
发布于 2013-07-16 15:24:28
尝尝这个
Update table
set status = 'YES'
where ID in ('1', '2', '3', '4', '5', '6')您还可以使用BETWEEN
Update table
set status = 'YES'
where ID BETWEEN '1' AND '6'发布于 2013-07-16 15:24:07
例如:
UPDATE files SET col_x = %s
WHERE ROWID in
(SELECT ROWID FROM table_name WHERE col_a = '%s' AND col_b = 0 );您可以使用嵌套查询来选择行,然后在单个语句中更新这些行。
发布于 2013-07-16 15:22:32
是的,在MYSQL中,您可以自由运行上述查询::
Update table
set status 'YES'
where ID in ('1', '2', '3', '4', '5', '6', etc)如果它是一个正常的序列,您可以尝试使用
之间的
Update table
set status 'YES'
where ID between 1 and n>= <=
Update table
set status 'YES'
where ID >=0 or ID<=nhttps://stackoverflow.com/questions/17670358
复制相似问题