I have two tables. I want to update table1
when the condition is satisfied. The condition here is to check the country in table 2
and if its Mex
, then multiply rate i.e. 0.5
to the price
.
I wrote the following code
UPDATE table1
SET table1.Price = (SELECT *,
CASE table2.Country
WHEN 'CANADA' THEN (1 * table2.price)
WHEN 'MEXICO' THEN (0.5 * table2.price)
ELSE 0
END AS Price_Calc
FROM table2)
FROM table1;
As I run this it gives the below error
Msg 116, Level 16, State 1, Line 12
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.