- Apr 29, 2005
- 5,649
- 0
- 0
I am trying to query WebTrends database tables.
Currently, when pulling active profiles names from one table and datasources from another, I get a list of each profile associated with each datasource parameter. That is not quite what I need though.
What I need is to compare those results against a third table that actually has the profile/datasource mappings so that the results show exactly which profile is using which datasource(s). Here's what I have currently:
I did have a LEFT JOIN and changed it to RIGHT JOIN to see if the results would be different (they weren't).
The third table is wt_ProfileDataSource which has two columns; DataSourceID and ProfileID. I don't have it in the query above b/c I am very new to SQL and I'm unsure of how to include it to compare against to get the desired results (the above query only showing a list of profiles with their actual mapped datasources (the contents of the third table) instead of a full list with every profile being displayed as if they were mapped to every datasource)
Thanks in advance for any help that comes my way.
Currently, when pulling active profiles names from one table and datasources from another, I get a list of each profile associated with each datasource parameter. That is not quite what I need though.
What I need is to compare those results against a third table that actually has the profile/datasource mappings so that the results show exactly which profile is using which datasource(s). Here's what I have currently:
select distinct TOP 1000 wtp.ProfileID
, wtp.ProfileName
, wtp.WRC_ProfileID
, wtp.TimeZoneID
, wtd.DataSourceID
, wtd.DCSID
, wtd.Name
From wt_profile wtp --, wt_DataSource wtd
RIGHT JOIN wt_DataSource wtd ON wtp.AccountID = wtd.AccountID
where wtp.profilestatusid like '1' or wtp.profilestatusid like '8' and wtd.DCSID like 'dcs%';
The third table only has two columns that it uses to map the profile to datasource: DataSourceID and ProfileID
I did have a LEFT JOIN and changed it to RIGHT JOIN to see if the results would be different (they weren't).
The third table is wt_ProfileDataSource which has two columns; DataSourceID and ProfileID. I don't have it in the query above b/c I am very new to SQL and I'm unsure of how to include it to compare against to get the desired results (the above query only showing a list of profiles with their actual mapped datasources (the contents of the third table) instead of a full list with every profile being displayed as if they were mapped to every datasource)
Thanks in advance for any help that comes my way.