Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Left Join with 3 Tables

$
0
0

This is a SQL question mostly so don't be put off by the SCCM references please.

I'm trying to query SCCM to get a list of ALL machines and the updates that apply to them. If there are no updates, just return null for those fields: A fairly simple left join. But I'm using 3 tables:

  • v_R_System_Valid : Computers with a unique ResourceId
  • v_UpdateInfo : Update info. Each update has a unique CI_ID
  • v_UpdateComplianceStatus : Has a ResourceId, a CI_ID and a status number

I can't seem to make it work. I've tried left outer, left, tried making a subselect for the update and update status tables, etc. Nothing seems to return ALL computers Anyone see what I've got wrong?

select d.Netbios_Name0 MachineName,
       u.ArticleID,
       u.BulletinID,
       u.Title UpdateTitle,
       u.DateCreated

from v_R_System_Valid d
left outer join v_UpdateComplianceStatus us on us.ResourceID = d.ResourceID
left outer join v_UpdateInfo u on u.CI_ID = us.CI_ID
where u.CIType_ID != 9
	and us.Status = 2
	and Operating_System_Name_and0 like '%server%'
order by MachineName



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>