Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Left Outer Join


Message #1 by "Rita Greenberg" <rg1@h...> on Tue, 3 Apr 2001 18:39:49
You need to use an OUTER join.

  Select PPONetworkID, Version, BuildPPONetworkID, BuildVersion
  From rBuilds LEFT OUTER JOIN sGroup
       On (PPONetworkID = BuildPPONetworkID And Version = BuildVersion)
  Where BuildPPONetworkID Is NULL

This type of join will return all of the rows in the first table, and 
would also return data from the second table if a corresponding row 
exists.  If none exists, the Build... columns will contain nulls.  
Therefore, if you constrain the result by requiring a column of the second 
table to be null, you will retrieve only rows from the first table that do 
not have a corresponding row in the second table.


> Hi.
> 
> I have 2 tables, rBUILDS and sGROUP.
> 
> rBUILDS             sGROUP
> -------             ------
> PPONetworkID        BuildPPONetworkID
> Version             BuildVersion
> 
> I'd like all the rows from rBUILDS for which there is no row in sGROUP 
> with the same PPONetworkID AND Version.
> 
> e.g.
>  
> rBUILDS             sGROUP
> -------             ------
> 09 2.5              09 3.0 
> 09 3.0
> 56 2.5
> 
> I need rows 09 2.5 and 56 2.5 from rBUILDS.
> 
> I've played around with Left Inner Joins but have had no success.
> 
> Any suggestions would be greatlu appreciated.
> 

  Return to Index