Not in or Not exists sql help please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VanessaG
    New Member
    • Feb 2012
    • 1

    #1

    Not in or Not exists sql help please

    help please.
    Im trying to find where a record has been created but no info has been added.
    Im using a database not created by me and finding the links between views is often quess work. I have only ever written really basic queries.

    Can anyone please explain how to add a NOT In or NOT exists clause to the query below (if thats the best way to do it?)


    Code:
    select name etc..... 
     
     from dbo.contact as con
    	join dbo.trainingagreement as ta 
    on con.ContactId = ta.traineeid
    	join dbo.trainingprogramme as tp on tp.trainingagreementid = ta.trainingagreementId
    	join dbo.trainingprogramplan as tpp on tp.trainingprogrammeId = tpp.trainingprogramid 
    	join dbo.programplanunit as ppu on tpp.trainingprogramplanid = ppu.trainingprogramplanid
    
    where tp.statuscode = 1 or tp.statuscode = 3


    this returns 80 000 odd records with all the column headers I want, what I want to know is how to see the records where Program Plan Units didn't create. Is this poss?

    thanks
    Last edited by Rabbit; Feb 16 '12, 05:14 AM. Reason: Please use code tags when posting code.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Typically, if a record doesn't exist, and is OUTER JOINed in SQL, then any refs to it's fields return Nulls. Check for Nulls then in the index field to find missing records.

    Comment

    Working...