[MYSQL] INTERSECT, MINUS

2011-10-16 Thread Grega Leskovšek
WHat is wring with the following three sentences? SELECT p.name, p.gender, e.pizza FROM Person p, Eats e WHERE p.name = e.name AND p.gender = 'female' AND (e.pizza = 'mushroom') INTERSECT SELECT p.name, p.gender, e.pizza FROM Person p, Eats e WHERE p.name = e.name AND p.gender = 'female' AND

Re: [MYSQL] INTERSECT, MINUS

2011-10-16 Thread Suresh Kuna
Hi, EXISTS function provides a simple way to find intersection between tables (INTERSECT operator from relational model). If we have table1 and table2, both having id and value columns, the intersection could be calculated like this: SELECT * FROM table1 WHERE EXISTS(SELECT * FROM table2 WHERE