Home > front end >  How can I update Table A columns (Price & Limit) from table B & C
How can I update Table A columns (Price & Limit) from table B & C

Time:10-06

Table to update

How can I update data into Table A with Single Update query?

CodePudding user response:

Try something like : (I haven't tested it)

BEGIN TRANSACTION

UPDATE tableA 
SET tableA.Price = tableB.Price
FROM tableA, tableB
WHERE tableA.Item = tableB.Item

UPDATE tableA 
SET tableA.Limit = tableC.Limit
FROM tableA, tableC
WHERE tableA.CName = tableC.CName

COMMIT

CodePudding user response:

try this request

UPDATE A a
SET a.price = b.price, a.limit = c.limit 
FROM B b, C c
WHERE a.item = b.item and a.cname = c.cname;
  •  Tags:  
  • sql
  • Related