Here's what I have:
members Table:
Stores info about member, such as address, marital status, etc
interests Table:
Stores interest_id, and interest_name
member_interests Table:
Keeps track of which members have selected which interests, member_id and interest_id
Now, what I need to do:
I need to compile a query (based on selected form elements) that selects member_id, name, and email address from the members table, where members match both the demographics selected AND the interests selected.
Obviously, this needs to query both the members table and the member_interests table. An example would be, selecting members from the USA, who are married, and who are interested in Golf. The two queries would be:
SELECT member_id, interest_id FROM member_interests WHERE interest_id = 25;
SELECT name, email, member_id FROM members WHERE country = 'US' AND marital_status = 'M';
Question is, is there ANY way to combine this into one query, and if so, what's the syntax? If not, am I stuck with querying the member_interests table (getting all matching member_id's), then adding those member_id's to the where clause of the other query? If anyong could give me some guidance, I'd appreciate it!
TIA!