José D.
José D.

Reputation: 4275

Trying relational division on oracle (right parenthesis missing?)

I'm trying to execute the following query in Oracle:

SELECT c.id_cliente, c.nombre_cliente, c.apellidos_cliente
FROM cliente c
WHERE not exists (SELECT f.id_finca
       FROM finca f
       WHERE f.habitaciones = 3
       EXCEPT
       SELECT v.id_fincas
       FROM visitas v
       WHERE v.id_cliente = c.id_cliente)

But I am getting the error "missing right parenthesis".

The parenthesis are well-balanced, how can I solve this error?

Upvotes: 0

Views: 122

Answers (2)

Dba
Dba

Reputation: 6649

Use MINUS instead of EXCEPT.

SELECT c.id_cliente, 
       c.nombre_cliente, 
       c.apellidos_cliente 
FROM   cliente c 
WHERE  NOT EXISTS (SELECT f.id_finca 
                   FROM   finca f 
                   WHERE  f.habitaciones = 3 
                   MINUS
                   SELECT v.id_fincas 
                   FROM   visitas v 
                   WHERE  v.id_cliente = c.id_cliente) 

Upvotes: 1

smnbbrv
smnbbrv

Reputation: 24581

there is no operator EXCEPT in Oracle. Use MINUS instead of it.

Additionally, your query seems weird: better try to make it with two not exists, I think it can give some performance.

Upvotes: 0

Related Questions