我有兩個表:
table1 has attributes: Price, Name (IS)
table2 has attribute: Price, Name (IS)
我想table1在table2何時使用價格條目更新價格條目table1.Name (IS)= table2.Name (IS)
UPDATE table1
SET Price= table2.Price
FROM table2
WHERE table2.Name (IS)= table1.Name (IS)
列不存在錯誤
uj5u.com熱心網友回復:
我認為你缺少一個選擇:
UPDATE table1
SET Price= (SELECT table2.Price
FROM table2
WHERE table2.Name = table1.Name)
uj5u.com熱心網友回復:
如果在列名中使用特殊字符需要在雙引號之間附加列名,如下例:
UPDATE table1
SET "Price" = table2."Price"
FROM table2
WHERE table2."Name (IS)" = table1."Name (IS)"
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/350382.html
標籤:sql PostgreSQL
