Question

Have few columns and tables, as follows:

NOTE: The names of elements used are for illustrative purposes only.

SELECT T.col1 
FROM Table1 T 
WHERE NOT EXISTS (
   (SELECT * FROM Table2) 
     EXCEPT (SELECT TT.col1 
             FROM TableTT TT 
             WHERE TT.col2 = T.col2)
     );

Error: Missing right parenthesis, though the parentheses seem to match.

But, I do know that it has nothing to do with the parenthesis actually. And I suspect the error to be somewhere in the EXCEPT clause. What might have resulted in the error?

Was it helpful?

Solution

There's no EXCEPT operator in Oracle. Use MINUS instead. Reference: Here

In your query the word 'EXCEPT' is most probably treated as a table alias for (SELECT * FROM Table2) subquery.

UPDATE:

Full query for provided data structure will look like:

SELECT T.col1 
FROM Table1 T 
WHERE NOT EXISTS 
((SELECT col1 FROM Table2) 
MINUS 
(SELECT TT.col1 FROM TableTT TT WHERE TT.col2 = T.col2));

Note that I have changed * to col1 for Table2 - if you're selecting single INT column TT.col1 from TT then you should also select single INT column from Table2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top