Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Join question

Author  Topic 

darms21
Yak Posting Veteran

54 Posts

Posted - 2013-03-25 : 12:47:34
Greetings,
I have the following tables:
Table A
UUID
Computer_Name

Table B
UUID
ProcedureUUID

Table C
ProcedureUUID
SW_Name

I have the following query which shows me all instances where SoftwareX is install on a system:
SELECT * 
FROM A JOIN B ON A.UUID = B.UUID
JOIN C ON B.ProcedureUUID= C.ProcedureUUID
WHERE SW_Name like 'SoftwareX'


I would like to be able, in one result set, to identify not only those systems that have SoftwareX installed but also system that do not.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-25 : 13:21:52
[code]
SELECT *
FROM A JOIN B ON A.UUID = B.UUID
LEFT JOIN C ON B.ProcedureUUID= C.ProcedureUUID
AND SW_Name like 'SoftwareX'
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

darms21
Yak Posting Veteran

54 Posts

Posted - 2013-03-25 : 15:11:29
I appreciate the help but that is not a solution to this query. That does not necessarily identify all records from Table A that may not be in Table B or Table C.

What I have come up w/ however that does appear to work is the following:

SELCT *
(SELECT *
FROM A JOIN B ON A.UUID = B.UUID
JOIN C ON B.ProcedureUUID= C.ProcedureUUID
WHERE SW_Name like 'SoftwareX') AS DRV1
RIGHT OUTER JOIN A on DRV1.Name = A.Name
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-26 : 14:45:59
[code]
SELECT *
FROM A LEFT JOIN B ON A.UUID = B.UUID
LEFT JOIN C ON B.ProcedureUUID= C.ProcedureUUID
AND SW_Name like 'SoftwareX'
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -