减号运算符给我在mysql中的错误 [英] Minus operator giving me erros in mysql

查看:89
本文介绍了减号运算符给我在mysql中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个查询.

当我对它们使用减号运算符时,第一个查询返回11行,第二个查询返回6行,据我所知应该返回5行

First query returning 11 rows and second query returning 6 rows when i use the minus operator on them it should return 5 rows as far as my understanding

 SELECT location from uploads where username='Gates'
 MINUS
 SELECT fileshare FROM `whiteboard` where username='Gates' and friend='Curlyclouds'

但是我遇到了以下错误:

But i am getting the following error:

您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本以使用正确的语法 接近减去whiteboard的SELECT文件共享",其中username ='Gates' 和friend ='Cur'在第二行

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 fileshare FROM whiteboard where username='Gates' and friend='Cur' at line 2

希望我的问题很清楚,任何帮助都会对我有所帮助...谢谢

Hope my question is clear and any help would be helpful to me .....Thank You

推荐答案

MySQL不支持EXCEPTMINUS.

MySQL does not support EXCEPT or MINUS.

您可以使用NOT EXISTSOUTER JOIN ... NULLNOT IN(请注意NULL)进行反半联接.

You can use NOT EXISTS , OUTER JOIN ... NULL or NOT IN (be careful of NULLs) to do an anti semi join.

在此处查看示例和性能比较

这篇关于减号运算符给我在mysql中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆