【发布时间】:2012-08-06 20:14:34
【问题描述】:
请帮我解决这个问题
sel a.col1,a.co2,a.col3,.........b.col1,b.col2..,c.col1,c.col2
from table1 as a inner join table2 as b on a.col1 =b.col1
inner join table3 as c on a.col1 = b.col1
where col1 = xxxxx;
现在我需要再加入一个表 table4。由于 table4 中没有 col1 作为主索引,因此我需要将其加入到另一个具有主键的表中。
以下是我需要将其包含在上述 sel 语句中的不同查询。
Sel xx.col1,yy.aaa,yy.bbb,zz.ccc,zz.ddd,zz.eee
from tablea as xx, tableb as yy, table4 as zz
where xx.col1 = yy.bbb and yy.aaa = zz.ccc
主索引:
- table1、table2、table3、tablexx 的 col1
- aaa 用于 tableb
- 表4的ccc
提前致谢
【问题讨论】:
-
THIS IS IN TERADATA------------ 我的足迹:sel a.col1, a.co2, a.col3,.........b .col1,b.col2...,c.col1,c.col2,zz.ccc,z z.ddd,zz.eee from table4 as zz,table1 as a inner join table2 as b on a.col1 =b.col1内连接表 3 作为 a.col1 上的 c = b.col1 内连接表 b 作为 a.col1 上的 yy = yy.bbb 和 yy.aaa = zz.ccc 其中 col1 = xxxxx;错误:3782 连接表的搜索条件中的列引用不正确 谢谢
-
在使表名和列名通用的过程中,您似乎引入了一些错误。因此,很难知道您是否遇到了问题,因为您的原始代码有语法错误,或者您是否在转换为通用名称时引入了它们。这是您的代码中明显错误的示例。您在第一个代码块中编写了“table 3 as c”。我假设您的意思是“table3 as c”。请使用示例表发布实际的 sql 或三次检查您翻译的 SQL 是否正确
-
@snoguy 。 . .可能是我在重新格式化查询时引入了一个杂散空间。
标签: sql database inner-join teradata