How to find Unequal Values from Two Tables

后端 未结 1 1405
一整个雨季
一整个雨季 2021-01-24 14:31

I am doing a left join query to compare the two tables for any values that do not equal each other on f9 and sumoff6 columns ONLY if the F1 columns are the same. If they are dif

相关标签:
1条回答
  • 2021-01-24 15:26

    The problem is that allocation_final.sumoff6 has a NULL value, and the WHERE condition filters out NULL values. Just test for this condition:

    SELECT statement.f1, statement.f9
    FROM statement LEFT JOIN
         allocation_final
         ON statement.[f1] = allocation_final[f1] 
    WHERE [allocation_final].sumoff6 <> statement.f9 OR
          [allocation_final].sumoff6 IS NULL;
    

    EDIT:

    Perhaps your join is in the wrong direction:

    SELECT allocation_final.f1, statement.f9, allocation_final.sumoff6
    FROM allocation_final LEFT JOIN
         statement
         ON statement.[f1] = allocation_final[f1] 
    WHERE allocation_final.sumoff6 <> statement.f9 OR
          statement.f9 IS NULL;
    

    Based on your sample data, this would make more sense.

    0 讨论(0)
提交回复
热议问题