Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 29, 2011 12:54 PM by gopalanmani
Member
7 Points
9 Posts
Dec 28, 2011 02:52 PM|LINK
I need to perform an intersect between these two queries to find out if some link has both status: 1- SELECT link as Active FROM monitor WHERE status = 1 2-SELECT link as Inactive FROM monitor WHERE status = 2 How can I do this with mysql?
Star
7826 Points
1320 Posts
Dec 29, 2011 12:54 PM|LINK
Hi,
MySQL doesn't support the set operator INTERSECT 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 table1.id=table2.id AND table1.value=table2.value) and also check this url, http://gablog.eu/online/node/33
joshua2005xx
Member
7 Points
9 Posts
doing an intersect on mysql
Dec 28, 2011 02:52 PM|LINK
I need to perform an intersect between these two queries to find out if some link has both status:
1- SELECT link as Active FROM monitor WHERE status = 1
2-SELECT link as Inactive FROM monitor WHERE status = 2
How can I do this with mysql?
gopalanmani
Star
7826 Points
1320 Posts
Re: doing an intersect on mysql
Dec 29, 2011 12:54 PM|LINK
Hi,
MySQL doesn't support the set operator INTERSECT
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 table1.id=table2.id AND table1.value=table2.value)
and also check this url,
http://gablog.eu/online/node/33
Gopalan Mani
My Tech blog