Update employee set a='a' where b=1
Update employee set a='b' where b=2
……
与
update employee set case when b=1 then a='a' when b=2 then a='b' else a='c'
更新速度一样?SQL update case
Update employee set a='b' where b=2
……
与
update employee set case when b=1 then a='a' when b=2 then a='b' else a='c'
更新速度一样?SQL update case
第二个语句CASE WHEN是更新了整个表的数据。自己做个测试就知道性能。
sql一切皆有可能
update employee set a=case when b=1 then 'a' when b=2 then 'b' else 'c' end
你那样写就直接报错了哦如#1所说,一般应该是分开写用where筛选较快