3
(SELECT IDOperatore FROM operatore) MINUS 
(SELECT IDOperatore FROM commessaoperatore GROUP BY IDOperatore)  

This query is no working, even if I try to replace MINUS with EXCEPT. The singular query SELECT IDOperatore FROM operatore and SELECT IDOperatore FROM commessaoperatore GROUP BY IDOperatore are working, but if I try to put together with Minus operator they don't work.

ERROR: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MINUS (SELECT IDOperatore FROM commessaoperatore GROUP BY IDOperatore)' at line 1

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
vankraster
  • 31
  • 1
  • 1
  • 2

1 Answers1

4

MINUS does not exists in mysql

however for you query you can use NOT EXISTS:

SELECT IDOperatore FROM operatore o
WHERE NOT EXISTS (SELECT 1
                 FROM commessaoperatore c 
                 WHERE c.IDOperatore = o.IDOperatore)
Michael Pakhantsov
  • 24,855
  • 6
  • 60
  • 59