MySQL Forums
Forum List  »  Newbie

intersect equivalent for mysql?
Posted by: c indigo
Date: September 10, 2004 03:04PM

here's the deal. i have a table that relates information from two other tables via the use of foriegn keys.

here is a sample:
fk1 -- fk2
1 -- 1
1 -- 2
1 -- 3
2 -- 2
2 -- 4
3 -- 3
3 -- 6
3 -- 7
4 -- 1

I need a query that will return the following result set:
fk_table1Id where fk_table2Id=1 and fk_table2Id=2 and fk_table2Id=3
(obviously this cannot be done this way b/c fk_table2Id cannot equal more than one condition). For this condition, I want to return 1, but not 2, or 3, or 4. With other databases I could just perform several different queries and intersect them, but mysql doesn't support an intersect. Anyone know of a good way to do this? BTW, this table has over 2 million rows, and time is a factor.

Thanks in advance,
Cindigo

Options: ReplyQuote


Subject
Written By
Posted
intersect equivalent for mysql?
September 10, 2004 03:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.