Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 comparison between two tables

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2008-05-12 : 11:54:27
Hi

I have two tables. One table called customers contains the records for all the customers of my firm. I have another table called "general"
which contains the details of all people(who are either my customers or not).

I want to compare my "general" table with my customers table to find out those who are not my customers using the name fields in both the tables.

how can i do that. Thanks in advance

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-12 : 11:58:49
[code]select g.*
from general g left join customers c
on g.name = c.name
where c.name is null[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-12 : 12:01:51
or:-

SELECT * from general where name not in (select name from customers)
Go to Top of Page

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2008-05-12 : 12:27:05
Thaks for the response
Go to Top of Page
   

- Advertisement -