I'm a bit stuck, I have the concept clear in my head but I cannot for the life of me work out how to code it in SQL...!!
For a site that I'm building, I'm implementing a banner system, the bit where I'm stuck relates to working out which Advertising Profiles apply to the current logged in Member.
These are the three tables...
tbl_members: This is a database table that includes members age, relationship status, sex, whether they have kids (T or F) etc.
tbl_adverts_profiles: This is a database table that has similar columns to the Member Profile table, they are populated by the site's owner depending on who he wants to target the Advert to (as adverts are associated via foreign key to this table) but some columns are left blank as the specific profile may want to capture all users whether they have kids or not, or whether they're male or female.
tbl_adverts: This is a table of adverts, within this table is a foreign key that links to the Advert Profiles table, therefore allowing associate of a specific advert banner with a specific member type.
With the current user logged in, I have all their details to hand in local variables, but how can I construct some SQL that will filter only Advert Profiles that relate to the member?
Here's an example. The member is a 25yr old Male WITH Kids and the following Advertising Profiles exist in the DB...
ProfileID AgeFrom AgeTo Gender HasKidsOrNot
1 16 30 M All
2 ALL ALL F T
3 25 40 M All
4 10 16 All F
The outcome recordset of the SQL query I need to run would give...
ProfileIDs: 1, 3
I appreciate your time/help in advance!!