0

I am getting

ORA-00907: missing right parenthesis

for the following query:

SELECT PEOPLE.NAME FROM
CLIENTS K INNER JOIN PEOPLE ON K.ID_L = PEOPLE.ID_L
WHERE NOT EXISTS
(
(SELECT DISTINCT ARTIST.ID_U
FROM CLIENTS INNER JOIN ADORES ON CLIENTS.ID_L = ADORES.ID_L
INNER JOIN ARTIST ON ADORES.ID_U = ARTIST.ID_U
WHERE CLIENTS.ID_L = K.ID_L)

EXCEPT

(SELECT DISTINCT ARTIST.ID_U
FROM CLIENTS INNER JOIN BOUGHT ON CLIENTS.ID_L = BOUGHT.ID_L
INNER JOIN ARTWORK ON BOUGHT.ID_D = ARTWORK.ID_D
INNER JOIN ARTIST ON ARTWORK.ID_U = ARTIST.ID_U
WHERE CLIENTS.ID_L = K.ID_L)
)

I've checked both subqueries - both are ok. It works if I remove the EXCEPT operator and only use one subquery (but I need to actually test that both are equal).

Any idea on what the problem is?

MDCCL
  • 8,530
  • 3
  • 32
  • 63
PerakR
  • 3
  • 1
  • 2

1 Answers1

2

EXCEPT is an SQL standard that is not available in Oracle. You probably want to use the Oracle equivalent of MINUS.

See here for a good answer on the two keywords.

Edit: @a_horse_with_no_name corrected thanks!

kevinskio
  • 4,272
  • 1
  • 30
  • 50