示例查询:
Select id, id_dtm
From tableA
Where exists (
Select 1
From tableB b, tableC c, tableD d
Where b.id = id
And b.id_dtm = id_dtm
And b.id = c.id
And c.id = d.id);
Run Code Online (Sandbox Code Playgroud)
上述查询的问题是所有4个表都有名为id和id_dtm的列.当我运行它时,我得到一个错误,表示列ORA-00918:列模糊定义
我可以通过在tableA中使用别名来修复,但问题是查询是动态生成的.该where exists部分是在其他地方生成的,之前的位合并,所以我不能使用现在的别名.
有没有什么办法可以在where exists子句中使用tableA中的id和id_dtm 而不使用tableA的别名?
数据库是Oracle10G
写表名tableA:
Select id, id_dtm
From tableA
Where exists (
Select 1
From tableB b, tableC, tableD
Where tableB.id = tableA.id
And tableB.id_dtm = tableA.id_dtm
And tableB.id = tableC.id
And tableC.id = tableD.id)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7580 次 |
| 最近记录: |