0

我正在尝试将来自不同架构的两个表连接到一个表中......这是我的查询。我不断收到错误消息,说它缺少右括号。谁能帮我解决这个问题?我已经尝试了我能想到的所有可能的解决方案。我不相信它缺少一个,但它不会起作用。这是我的查询:

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); 
4

3 回答 3

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

目前尚不清楚为什么您需要来自第三模式的此字段

于 2013-05-07T02:33:32.017 回答
1

导致您的问题的多余括号是第一个附近的括号select

create view  customers_g2 as (
select ( -- here
(schema1.INTX.CUST_ID, 

此外,后面的部分周围的括号as并不是绝对必要的(请参见此处)。

你可能想要一种不同的加入:

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;

(警告:我所知道的关于加入的一切都来自这里;如果我错了,请叫我。)

于 2013-05-07T02:56:15.690 回答
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;
于 2013-05-07T02:48:35.403 回答