WHERE conditions in subquery while using ANSI joins
문제
Why doesn't it work?
SELECT a.*
FROM dual a
JOIN (SELECT * FROM dual WHERE 1=1) b
ON (1=1);
I get "ORA-00900: invalid SQL statement". Is there a way to use WHERE clause inside the subquery?
Edit: Version 9.2
SELECT *
FROM v$version
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
The following executes just fine:
SELECT a.*
FROM dual a
JOIN (SELECT * FROM dual /*WHERE 1=1*/) b
ON (1=1)
해결책
It works for me on 9.2 (32 bit version is the only difference):
SQL> SELECT a.*
2 FROM dual a
3 JOIN (SELECT * FROM dual WHERE 1=1) b
4 ON (1=1);
D
-
X
SQL> quit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
다른 팁
What version are you using?
The exact same SQL works fine for me (Oracle Database 10g Express Edition Release 10.2.0.1.0).
Oracle below 9i
does not support ANSI
join syntax.
Use this if you're on 8i
and below:
SELECT a.*
FROM dual a,
(
SELECT *
FROM dual
WHERE 1 = 1
) b
WHERE 1 = 1
It looks correct to me and I am able to execute it in 10g, but it fails with 8i, which version of Oracle are you using?
제휴하지 않습니다 StackOverflow