Oracle JOIN USING子查询:ora-00904字符串:无效的标识符

我的查询中有一点语法问题(简化):

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)

dawei

【声明】:北京站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。