gpt4 book ai didi

mysql - 编写多个 UPDATE 查询的更有效方法

转载 作者:搜寻专家 更新时间:2023-10-30 21:47:29 24 4
gpt4 key购买 nike

是否有更好/更高效/更短的方式来编写此 SQL 查询:

UPDATE mTable SET score = 0.2537 WHERE user = 'Xthane' AND groupId = 37;
UPDATE mTable SET score = 0.2349 WHERE user = 'Mike' AND groupId = 37;
UPDATE mTable SET score = 0.2761 WHERE user = 'Jack' AND groupId = 37;
UPDATE mTable SET score = 0.2655 WHERE user = 'Isotope' AND groupId = 37;
UPDATE mTable SET score = 0.3235 WHERE user = 'Caesar' AND groupId = 37;

最佳答案

UPDATE mTable 
SET score =
case user
when 'Xthane' then 0.2537
when 'Mike' then 0.2349
when 'Jack' then 0.2761
when 'Isotope' then 0.2655
when 'Caesar' then 0.3235
else score
end
where groupId = 37

关于mysql - 编写多个 UPDATE 查询的更有效方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11690494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com