update Claim
set first_name = random_name(7),
Last_name = random_name(6),
t2.first_name=random_name(7),
t2.last_name=random_name(6)
from Claim t1
inner join tbl_ecpremit t2
on t1.first_name = t2.first_name
我得到以下錯誤這些表之間沒有關係(PK,FK)更新與相同的數據的兩個表,其中有
column "t2" of relation "claim" does not exist
目前還不清楚你想要做什麼。你想從表「tbl_ecpremit」中的數據更新表「索賠」還是你想在這兩個表中插入相同的新數據? – Patrick
我想在兩個表中插入更新的新數據。 – user4287146
不相關,但:從'tb1'聲明中刪除''。 [引自手冊](http://www.postgresql.org/docs/current/static/sql-update.html):「*請注意,目標表必須**不**出現在from_list中,除非您打算自我加入(在這種情況下,它必須在from_list中出現一個別名)*「 - 你真的打算在這裏自我加入嗎?即使兩個表都是連接條件的一部分,您也可以不使用單個UPDATE語句更新兩個不同的表。 –