我正在尝试将来自不同架构的两个表连接到一个表中....这是我的查询。我一直收到一个错误,说它缺少右括号。任何人都可以帮我解决这个问题吗?我已经尝试了我能想到的所有可能的解决方案。我不相信它缺少一个,但它不会起作用。这是我的疑问:
create view customers_g2 as
select (
(schema1.INTX.CUST_ID,
schema1.INTX.CUST_NAME,
schema1.INTX.CUST_GENDER,
schema1.INTX.CUST_STATE,
schema1.INTX.COUNTRY_ID)
Join
select (KWEKU.KM_CUSTOMERS_EXT.CUST_ID,
schema2.EXT.CUST_AGE,
schema2.EXT.CUST_EDUCATION,
schema2.EXT.MARRIED,
schema2.EXT.NO_OF_CHILDREN,
schema2.EXT.RACE,
schema2.EXT.INCOME,
schema2.EXT.CHECKING_BAL,
schema2.EXT.SAVINGS_BAL,
schema2.EXT.ASSETS,
schema2.EXT.HOUSES)
from schema1.INTX,schema2.EXT
where schema1.INTX.CUST_ID = schema2.EXT.CUST_ID);
答案 0 :(得分:4)
尝试更改
create view customers_g2 as (
^ remove this parenthesis
到
create view customers_g2 as
更新:更好地将整个事情改为
CREATE VIEW customers_g2
AS
SELECT i.CUST_ID,
i.CUST_NAME,
i.CUST_GENDER,
i.CUST_STATE,
i.COUNTRY_ID,
e.CUST_AGE,
e.CUST_EDUCATION,
e.MARRIED,
e.NO_OF_CHILDREN,
e.RACE,
e.INCOME,
e.CHECKING_BAL,
e.SAVINGS_BAL,
e.ASSETS,
e.HOUSES
FROM schema1.INTX i JOIN
schema2.EXT e ON i.CUST_ID = e.CUST_ID
唯一不合适的是
KWEKU.KM_CUSTOMERS_EXT.CUST_ID
目前还不清楚为什么需要第三种模式的
这个字段答案 1 :(得分:1)
你的sql太奇怪了.. 这是你想要的吗?
create view customers_g2 as
select
schema1.INTX.CUST_ID,
schema1.INTX.CUST_NAME,
schema1.INTX.CUST_GENDER,
schema1.INTX.CUST_STATE,
schema1.INTX.COUNTRY_ID,
schema2.EXT.CUST_ID,
schema2.EXT.CUST_AGE,
schema2.EXT.CUST_EDUCATION,
schema2.EXT.MARRIED,
schema2.EXT.NO_OF_CHILDREN,
schema2.EXT.RACE,
schema2.EXT.INCOME,
schema2.EXT.CHECKING_BAL,
schema2.EXT.SAVINGS_BAL,
schema2.EXT.ASSETS,
schema2.EXT.HOUSES
from schema1.INTX,schema2.EXT
where schema1.INTX.CUST_ID = schema2.EXT.CUST_ID;
答案 2 :(得分:1)
造成问题的无关括号是靠近第一个select
:
create view customers_g2 as (
select ( -- here
(schema1.INTX.CUST_ID,
此外,as
之后的部分周围的parens并非绝对必要(请参阅here)。
您可能想要一种不同的联接:
create view customers_g2 as
select ...long long list of all your columns...
from schema1.INTX inner join schema2.INTX
on schema1.INTX.CUST_ID = schema2.EXT.CUST_ID;
(警告:我所知道的关于加入的所有内容都来自here;如果我错了,请打电话给我。)