user1529342 user1529342 - 7 months ago 33
MySQL Question

Minus operator giving me erros in mysql

I have two queries.

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'
SELECT fileshare FROM `whiteboard` where username='Gates' and friend='Curlyclouds'

But i am getting the following error:

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
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 does not support EXCEPT or MINUS.

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

See examples and performance comparisons here