想請問我有 a表 b表 兩表的欄位相同,要如何比對兩表,將A表沒有的key資料,插入
程式碼如下:
INSERT INTO well_info
select w.key ,w.site_name
from well_test as w
where w.key <> well_info.key
出現錯誤告訴我說,沒有 well_info.key
ERROR: invalid reference to FROM-clause entry for table "well_info"
LINE 4: where w.site_no <> well_info.site_no
^
HINT: There is an entry for table "well_info", but it cannot be referenced from this part of the query.
SQL 状态: 42P01
字符: 199
我嘗試多種方法
INSERT INTO well_info
select w.key ,w.site_name
from well_test as w
where w.key <> (select key from well_info)
外合併查詢也試過 都無法解決