Sebastian
Sebastian

Reputation: 43

How to run a query for each row from a table?

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

Answers (1)

AdrianBR
AdrianBR

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

Related Questions