Reputation: 43
I have a query that returns a list of Advertisers, each Advertisers has several Brands attached to it.
So I'm running this:
select distinct Name from tblAdvertiser
inner join tblAvertiserBrand on AdvertiserID=ID
So this would return a list of Advertisers and I'm trying to write a query that would loop for each row of the list that the query above would give in an automatic manner, any ideas?
Upvotes: 4
Views: 19194
Reputation: 2588
SQL 'loops' by default
SELECT *
FROM TABLE WHERE advertiser_name IN
(SELECT DISTINCT Name
FROM tblAdvertiser
INNER JOIN tblAvertiserBrand ON AdvertiserID=ID)
Upvotes: 5