DIT Support. Powered by Blogger.

Sunday, May 17, 2015

Select Data from one Table not in another SQL Server

by Unknown  |  in Programming at  7:38 PM

 Select data from one table not in another SQL Server

Method 1:
SELECT t1.name
FROM table1 t1
LEFT JOIN table2 t2 ON t2.name = t1.name
WHERE t2.name IS NULL
 
 Method 2:
SELECT name
FROM table2
WHERE name NOT IN
    (SELECT name 
     FROM table1)
 

Method 3:
SELECT name 
FROM table2 
WHERE NOT EXISTS 
    (SELECT * 
     FROM table2 
     WHERE table1.name = table2.name)

Method 4:
SELECT name
FROM table2
WHERE name NOT IN
    (SELECT name 
     FROM table1)

Method 5:
select id, name from table1
minus
select id, name from table2



0 comments:

    Popular Posts

Proudly Powered by Blogger.