SQL查询运算符减号不起作用

时间:2011-01-21 07:41:59

标签: php mysql except

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

即使我尝试将MINUS替换为EXCEPT,此查询也无效。 单数查询SELECT IDOperatore FROM operatoreSELECT IDOperatore FROM commessaoperatore GROUP BY IDOperatore正在运行,但如果我尝试与Minus运算符放在一起,则它们无效。

  

错误:#1064 - 您的SQL语法出错;查看与MySQL服务器版本对应的手册,以便在第1行“MINUS(SELECT IDOperatore FROM commessaoperatore GROUP BY IDOperatore)”附近使用正确的语法

1 个答案:

答案 0 :(得分:3)

mysql中不存在MINUS

但是对于您的查询,您可以使用NOT EXISTS:

SELECT IDOperatore FROM operatore o
WHERE NOT EXISTS (SELECT 1
                 FROM commessaoperatore c 
                 WHERE c.IDOperatore = o.IDOperatore)