Skip to content
Loading
  • Bikesh Srivastava
    0
    Hi Amit,
    I have already done this logic you can use query like this.
    1. SELECT*
    2. FROMTable2A
    3. WHERENOTEXISTS
    4. (
    5. SELECT*
    6. FROMTable1B
    7. WHEREA.[Company]=B.[Company/Account]
    8. );
    Mark as answer if find exact answer.
    0
  • Manas Mohapatra
    0
    You can use NOTIN or EXCEPT or LeftJoin to achieve the result.
    1. --Using NotIn  
    2. select * from table1 where productid NOT IN(select * from table2)  
    3.   
    4. --USE EXCEPT  
    5. select * from table1  
    6. except  
    7. select * from table2 
    Difference between Except and NotIn is: Except return distinct records but NotIn doesn't.
     
    http://dba.stackexchange.com/questions/83684/except-operator-vs-not-in
    0
  • snowal raj
    0
    it have 2 types 
     
    1.Using Not in
     
    SELECT *
    FROM Table1
    WHERE ID NOT IN
    (SELECT ID
    FROM Table2)
     
    but its not get all  records in all time
     
    2.Using Join
     
     
    SELECT A.ID
    FROM TABLE1 A
    LEFT JOIN TABLE2 B ON A.ID=B.ID
    WHERE A.ID IS NULL
    Its Give Perfect result in any time
    0