Reputation: 1758
i have table with same fields,want to update that fields,with where clause,
update tmp_aus_inv_data
SET cust_region= "ROTOMOULD"
WHERE division = "ROTOMOULD" ;
update tmp_aus_inv_data
SET cust_region= "Internal"
WHERE division = "EXTRUSION" and ucase(cust_region) like ucase('Internal%') ;
i tried with this,but not working,
update tmp_aus_inv_data
(set cust_region= "ROTOMOULD"),
(SET cust_region= "Internal")
WHERE division = "ROTOMOULD" and WHERE division = "EXTRUSION" and ucase(cust_region) like ucase('Internal%') ;
Upvotes: 0
Views: 80
Reputation: 247840
You can use a CASE
statement in your UPDATE
, so I think you want something like this:
update tmp_aus_inv_data
SET cust_region
= case
when division = "ROTOMOULD" then "ROTOMOULD"
when division = "EXTRUSION"
and ucase(cust_region) like ucase('Internal%')
then "Internal"
else cust_region
end
where division in ("ROTOMOULD", "EXTRUSION")
Upvotes: 3
Reputation: 59
Can you please try the below query once.
UPDATE tmp_aus_inv_data
SET `cust_region`= if(`division`= 'ROTOMOULD', 'ROTOMOULD', 'Internal')
WHERE division in ('ROTOMOULD','EXTRUSION');
Upvotes: 1