Hi again
Thanks alot for your help.
I have not yet made the tables... It is a future project, that's why I want to get it right from the start...
So if I take an American ex.
A filter table contains all the American states:
filter_id 1
filter California
filter_id 2
filter Washington
and so on...
The advertisers has in an ad_filters table chosen a location ex. like this:
ad_id 1
filter_id 1
ad_id 2
filter_id 2
ad_id 3
filter_id 1
ad_id 3
filter_id 2
And two costumers has in a cust_filters table chosen this:
cust_id 1
filter_id 1
cust_id 2
filter_id 1
cust_id 2
filter_id 2
So now I'm a little new at this 🙂
How do I get a query to find the advertisers that matches costumers so that costumer 1 matches advertiser 1 and 3 and costumer 2 matches advertiser 1, 2 and 3 ?
Only one of the filters has to match.
Is this close to correct if I need to list which advertisers that matches costumer 2ex.:
SELECT * FROM ad_filters LEFT JOIN cust_filters
ON (ad_filters.filter_id = cust_filters.filter_id)
WHERE cust_filters.cust_id='2'
GROUP BY ad_filters.ad_id
ORDER BY ad_filters.ad_id