filter records

palani_chamy

New member
Local time
Tomorrow, 04:31
Joined
Jul 20, 2011
Messages
2
i have both tables as table1 and table2 with same fields. the no.of records in table1 is more than the no.of records in table2. how to filter those records not found in table2. fields in both the tables are
srcode,vilcode,sncode,sdcode
 
Last edited:
Hi..

For all the fields to check..:

Code:
select *
 from table1
    where srcode & vilcode & sncode & sdcode 
     not in (
      select (srcode & vilcode & sncode & sdcode) from table2)

Or..:

Code:
select *
from table1 as a
where not exists (
                       select 1 from table2 as b  where 
                           b.srcode & b.vilcode & b.sncode & b.sdcode =  
                           a.srcode & a.vilcode & a.sncode & a.sdcode )


Second method (with exists) is more effective.
 

Users who are viewing this thread

Back
Top Bottom