我正在更改数据库模式,并将列“seat”从旧表移动到新表。首先,我在新表中添加了一个“seat”列。现在我试图用旧表中的值填充列。
UPDATE new_table
SET seat = seat
FROM old_table
WHERE old_table.id = new_table.ot_id;
返回错误:列引用“seat”不明确。
UPDATE new_table nt
SET nt.seat = ot.seat
FROM old_table ot
WHERE ot.id = nt.ot_id;
返回错误:关系“NeXiTABLE”的列“NT”不存在
思想?
最佳答案
UPDATE new_table
SET seat = old_table.seat
FROM old_table
WHERE old_table.id = new_table.ot_id;
关于sql - 使用FROM子句更新Postgres中的记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2760378/