I would like to create an INTERSECTion of the following two queries using MySQL:
1) SELECT atn_nid, atn_select_flag, atn_image_name
FROM city, attraction WHERE cty_nid = atn_cty_nid AND cty_nid = 5;
2) SELECT atn_nid, s2a_image_select_flag, atn_image_name
FROM segment, seg2atn, attraction WHERE seg_nid = s2a_seg_nid AND
s2a_atn_nid = atn_nid and seg_nid = 68 AND
s2a_image_select_flag = true;
Note: The atn_select_flag in Query 1 and the s2a_image_select_flag are both Boolean
Since MYSQL for some reason does not support INTERSECT, I am at a loss as to the syntax to use to accomplish this. Any help would be gratefully appreciated.
If I assume correctly that:
atn_...,cty_...,seg_..., ands2a_...belong toattraction,city,segment, andseg2atn, respectively...._nidare primary keys.atn_cty_nid,s2a_seg_nid, etc., are foreign keys.then your first query is equivalent to this:
and your second query is equivalent to this:
so their intersection is this:
and (edited to add) their union is this: