sql - TSQL, select values from large many-to-many relationship -


I have two tables publishers and campaigns, there are many relationships with both countries, regions, languages ​​and categories.

More info

Publisher2categories have a publisher and category ID, which are foreign keys for identifiers columns in categories in publisher and publisher IDs. On the other hand, I have campaign membership with Campaign ID and Category ID columns, which are the foreign keys for campaign IDs in campaigns and category IDs that are re-identifying.

P>

thanks

joining Publishers and campaigns and unions each individual multiple tables should leave you with all campaigns that are related to one of the publishers and camps Relationship tables.

  Select cc.CampaignID from dbo.PublisherSites2ountries PC INNER Join dbo.Campaings2ountries CC cc.CountryID = pc.CountryID Union Select PR.CampaignID dbo.PublisherSites2Regions PR Join INNER Dbo .Campaings2Regions cr on cr.RegionID = pr.RegionID ...  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -