我正在尝试使用不包含B表中的account_id的A表创建一个新表。但是,我遇到了一个错误:
错误:列“ owner_name”指定了多次
Create table dallas_50000_2
AS SELECT * from "2018_texas_county_dallas_individuals_person" A
LEFT JOIN dallas_50000_copy B
ON A.account_id = B.account_id
WHERE B.account_id IS NULL;
答案 0 :(得分:0)
您应该显式引用至少一个具有公共列的表的所有列名称(例如:-owner_name和account_id),并仅指定一次,或者为公共列名称提供单独的别名。否则,将变得模糊不清将哪个列用于目标表的列。
Create table dallas_50000_2
AS SELECT A.* , B.col1 , B.col2 --other columns that are not common to A
from "2018_texas_county_dallas_individuals_person" A
LEFT JOIN dallas_50000_copy B
ON A.account_id = B.account_id
WHERE B.account_id IS NULL;
OR
Create table dallas_50000_2
AS SELECT A.account_id as a_account_id, A.owner_name as A_owner_name,
B.col1 , B.col2,B.owner_name as B_owner_name
from "2018_texas_county_dallas_individuals_person" A
LEFT JOIN dallas_50000_copy B
ON A.account_id = B.account_id
WHERE B.account_id IS NULL;