Often we need MINUS operator as defined by the SQL definitions i.e you have two sets P and Q and you want P-Q which gives all the elements in P that are not in Q. But unfortunately, MYSQL does not have any operator for such an operation (yeah, I had the same reaction when I heard this!!).
So here is a way how you can implement it in MYSQL. For simplicity let us consider we have two tables P and Q (we can also have views, joins, etc instead of the tables here) which have atleast one column in common (say id, which usually will be the primary key) and we want to evaluate P - Q which removes all those rows from P whose id is present in Q.
Here is the SQL statement for it. The statement is quite self explanatory, but if you still have doubt then leave a comment.
[cc lang=“java”] Select * from P left join Q on P.id = Q.id where Q.id is NULL; [/cc]
Thats is what I could think of. If you are using some better and efficient method, then please leave a comment.