• Don. (1/29/2013)


    Hi Guys,

    I was working on a script that would show all records in Table A that didnt have corresponding records in Table B.

    I thought it would be simple enough and wrote the script below, which returned 0 rows.

    There should definitely be a couple thousand rows returned and am fairly concerned \ curious as to why the script below is incorrect.

    Select * from Contact1

    Where Company <> 'Z_CANDIDATE'

    And Accountno not in (Select Distinct Client_Accountno from RSM_KPI)

    I amended the script to the script below, and its returned the correct results.

    Select * from Contact1

    Where Company <> 'Z_CANDIDATE'

    AND NOT EXISTS (Select Client_Accountno from RSM_KPI Where RSM_KPI.Client_Accountno = Contact1.Accountno)

    Could someone explain \ point me to some links that would explain the discrepancy?

    Thanks

    Don

    Second Query does row by row check for the Contact table record in RSM_KPI table record ;

    First query , just check if any record of account_no in contacts table is not present in RSM_KPI table ; I guess it should return true for both Exists and Not Exists..

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm: