开发者

Is there a faster way to write those 3 same queries?

开发者 https://www.devze.com 2023-03-24 04:04 出处:网络
Is there any faster query way of rewriting these queries or by combining them? update products set shop = \'1\'

Is there any faster query way of rewriting these queries or by combining them?

update products
set shop = '1' 
where shop LIKE '%demo%'

update products
set shop = '2' 
where shop LIKE '%car%'

update products
set shop = '3' 
where shop LIKE '%a开发者_如何学Crt%'


update products
set shop =
case 
when shop like '%demo%' then 1
when shop like '%car%' then 2
when shop like '%art%' then 3
else shop
end


Maybe a stored procedure: http://www.sqlinfo.net/mysql/mysql_stored_procedure_UPDATE.php

0

精彩评论

暂无评论...
验证码 换一张
取 消