Sql 使用FROM子句更新Postgres中的记录
我正在更改我的db模式,并将列“seat”从旧的\u表移动到新的\u表。首先,我在新表中添加了一个“seat”列。现在我尝试用旧表中的值填充该列Sql 使用FROM子句更新Postgres中的记录,sql,postgresql,Sql,Postgresql,我正在更改我的db模式,并将列“seat”从旧的\u表移动到新的\u表。首先,我在新表中添加了一个“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
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;
返回错误:关系“new_table”的列“nt”不存在
想法?IIRC要更新的表格是不能使用别名的表格。你试过这个吗
UPDATE new_table
SET seat = ot.seat
FROM old_table ot
WHERE ot.id = ot_id;
IIRC要更新的表不能有别名。你试过这个吗
UPDATE new_table
SET seat = ot.seat
FROM old_table ot
WHERE ot.id = ot_id;
你应该可以只提到
座位
,就像这样
UPDATE new_table nt
SET seat = ot.seat
FROM old_table ot
WHERE ot.id = nt.ot_id;
你应该可以只提到
座位
,就像这样
UPDATE new_table nt
SET seat = ot.seat
FROM old_table ot
WHERE ot.id = nt.ot_id;
我认为这不是特定于PostgreSQL,而是标准SQL我认为这不是特定于PostgreSQL,而是标准SQL