Need to find rows in one table which does NOT match data in 2nd table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RavenTim
    New Member
    • Mar 2010
    • 2

    Need to find rows in one table which does NOT match data in 2nd table

    I have two tables, storage1 and storage2. These tables are setup differently however, storage1.custbo x contains data that may match one, two or three columns from storage2, which are storage2.custbo xnbr, storage2.boxnbr , storage2.refere nce1(if there's a match, it would just be one row). I'm trying to find the rows in storage2 where the data in storage2.custbo xnbr, storage2.boxnbr , storage2.refere nce1 have no match to storage1.custbo x. There are also some rows where these fields are empty, but I don't want these empties returned in the select.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    try if this will work..

    Code:
    select * 
    from storage2 s2
    where not exists (select 1 from storage1 s1 where s1.custbox not in (storage2.custboxnbr, storage2.boxnbr, storage2.reference1)
    Happy Coding!!!

    ~~ CK

    Comment

    • RavenTim
      New Member
      • Mar 2010
      • 2

      #3
      The query runs, but finds zero records... It should find about 7,000 rows. Thanks anyway.

      Comment

      Working...