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
 Transact-SQL (2000)
 JOIN with a not equal to

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-05-26 : 09:27:52
Jeremiah writes "Platform:
SQL Server 2000
Windows NT 4.0 Service pack 6

Question:

I have "table1" with customer records and phone numbers and "table2" with phone numbers. I want to join the two tables and return only the records from "table1" that were not equal to the phone numbers in "table2".

I can only seem to get the ones that are = and not !=.

Thanks for your help in advance."

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-05-26 : 10:12:31
You need an OUTER JOIN here:

SELECT table1.CustomerName, table1.PhoneNumber
FROM table1
LEFT OUTER JOIN table2
ON table1.PhoneNumber = table2.PhoneNumber
WHERE table2.PhoneNumber IS NULL


OS

Go to Top of Page
   

- Advertisement -