Reputation: 8836
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 '%art%'
Upvotes: 2
Views: 101
Reputation: 12592
Maybe a stored procedure: http://www.sqlinfo.net/mysql/mysql_stored_procedure_UPDATE.php
Upvotes: 0
Reputation: 56357
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
Upvotes: 4