trouble with select

  • The select works but its not the results I want. It right now it is omitting ALL the dates in missing logs. I need to omit the dates by contractornum(ID Number in missing logs) in missing logs. I am close but not sure how to add the contraint by contractornum

    SELECT logs.[date],contractornum from logs where logs.[date] not in(SELECT missing_logs.[date] from missing_logs inner join logs on missing_logs.[ID Number] = logs.contractornum) order by logs.[date]

    Matt

  • If I understand what you are trying to do, give this a shot:

     
    
    SELECT
    l.[date],
    l.contractornum
    from logs l
    where not exists (select * from missing_logs m where l.[date] = m.[date]
    and l.contractornum = m.[ID Number])
    order by l.[date]

    -Dan


    -Dan

  • Another possible solution:

    
    
    SELECT l.[date], l.contractornum FROM logs l LEFT JOIN missing_logs m where l.[date] = m.[date] and l.contractornum = m.[ID Number]
    WHERE m.[ID Number] IS NULL
    AND m.[Date] IS NULL
    ORDER BY l.[date]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply