(psycopg2.ProgrammingError)缺少表“ t”的FROM子句条目

时间:2018-10-20 02:09:21

标签: postgresql insert

尝试使用postgres从t插入表s时出现错误,

INSERT INTO s (name, site_square_footage)
SELECT name, site_square_footage
FROM temp_sites AS t
ON CONFLICT (name)
    DO UPDATE SET 
        site_square_footage = t.site_sqaure_footage

请帮助,谢谢!

1 个答案:

答案 0 :(得分:0)

我通过参考postgres文档找出答案,语法有点奇怪。

INSERT INTO s (name, site_square_footage)
SELECT name, site_square_footage
FROM temp_sites AS t
ON CONFLICT (name)
    DO UPDATE SET 
        site_square_footage = excluded.site_sqaure_footage