update columns values with column of another table based on condition [duplicate] update columns values with column of another table based on condition [duplicate] sql-server sql-server

update columns values with column of another table based on condition [duplicate]


Something like this should do it :

UPDATE table1    SET table1.Price = table2.price    FROM table1  INNER JOIN  table2 ON table1.id = table2.id

You can also try this:

UPDATE table1    SET price=(SELECT price FROM table2 WHERE table1.id=table2.id);


This will surely work:

UPDATE table1SET table1.price=(SELECT table2.price  FROM table2  WHERE table2.id=table1.id AND table2.item=table1.item);