Here are my tables .. I have table 1 and table2
I want an expression in SQL to update the price of car in table 1 if it is = 0 .. by set the price of the car same as the another product which has the same integer on ( Table2.N
). .. and the same date ( Table1.Date
)
I want the car price be the same as house price on april ( date
) (I chose house because car and house has same record on ( Table2.N
)
UPDATE Table1 SET Price = t.Price
FROM
(
SELECT Price, N
FROM Table2
WHERE Product-N != 'Car'
) t
WHERE (Table1.Product-N = 'Car' AND Table1.Price = 0 AND Table1.N = t.N AND Table1.Date = t.Date)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.