【发布时间】:2018-08-25 21:10:19
【问题描述】:
我有一个值列表,我想与 where 子句匹配以更新标志。
(col1, col2, col3)
(1, 2, 3)
(2, 3, 4)
(3, 4, 5)
如果过滤列表仅由一列组成,我会这样做:
update mytable
set flag=1
where col1 in ('1','2','3','5','8','13');
这个查询适合我的目的吗?
update mytable
set flag=1
where col1 in ('1','2','3')
and col2 in ('2','3','4')
and col3 in ('3','4','5');
如果表有记录 (1,3,5),查询将更新标志,但过滤列表不会被正确考虑。
是否可以对过滤列表的所有列使用 where 子句?例如
where (col1, col2, col3) in (???)
【问题讨论】:
标签: mysql sql-update