SELECT table1.col1, table2.col2
FROM table1
WHERE col3
IN(SELECT col1 FROM table3 WHERE col4 IN(SELECT col4 FROM table4 WHERE col5 LIKE '%XYZ%'))
INNER JOIN table2 ON table1.col1=table2.col6
ORDER BY table1.col1
I get a ORA00933 error.SQL command not properly ended.
If I remove the join, the query works perfectly. But i need the join. The error is near the LIKE keyword. How can I solve it?
You have misplaced the INNER JOIN
, it was located in your WHERE
clause.
Note that you might want to adopt some formatting scheme for writing SQL Statements. It makes it much easier to spot these kind of errors.
SELECT table1.col1, table2.col2
FROM table1
INNER JOIN table2 ON table1.col1=table2.col6
WHERE col3 IN (
SELECT col1
FROM table3
WHERE col4 IN (
SELECT col4
FROM table4
WHERE col5 LIKE '%XYZ%'
)
)
ORDER BY table1.col1
Try moving your join up ahead of your WHERE
clause:
SELECT table1.col1, table2.col2
FROM table1
INNER JOIN table2 ON table1.col1=table2.col6
WHERE col3
IN(SELECT col1 FROM table3 WHERE col4 IN(SELECT col4 FROM table4 WHERE col5 LIKE '%XYZ%'))
ORDER BY table1.col1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.