我的查询中有一点语法问题(简化):
select * from table1 t1 inner join table2 t2 using (pk1) inner join table3 t3 using (pk2) where not exists (select1 from table4 t4 where t4.pk1 = t1.pk1)
通过使用“using”关键字,oracle不允许在列名前面使用表标识符(例如:t1.pk1,只能使用pk1)
如果我写:
select * from table1 t1 inner join table2 t2 using (pk1) inner join table3 t3 using (pk2) where not exists (select1 from table4 t4 where t4.pk1 = pk1)
此查询不会给出预期的结果.
但由于我使用的是“存在”子查询,我如何加入此子查询?
当然,我想我可以用另一种方式编写这个查询并避免存在,或者我不能使用“使用”.
但是,是否可以在where子句中将“join / using”与子查询结合使用?
编辑:使用Oracle 10gR2
解决方法
有趣的问题!我仍然使用USING时可以管理的最好的是:
select * from ( select * from table1 t1 inner join table2 t2 using (pk1) inner join table3 t3 using (pk2) ) v where not exists (select1 from table4 t4 where t4.pk1 = v.pk1)