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)
 matching fields

Author  Topic 

paul.rowling
Yak Posting Veteran

81 Posts

Posted - 2003-04-10 : 07:44:10
Hi,

I have two tables, a customer table and another table called pro.

I want to be able to find all those customers in pro where the following fields = the same fields in the customer table:

Forename
Surname
Company_Name

Both tables have a customer_id for each customer although the customer id's in the customer table don't correspond to the customer id's of the same person in the pro table.

I think this should be simple, but I've been thinking about it too much and I've got myself confused. I also need to make sure that this is accurate.

Cheers

Paul

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-04-10 : 08:08:24
I am not quite sure of the question, but is this something close to what you want?

SELECT Pro.* FROM
Pro INNER JOIN Customer
ON Pro.ForeName = Customer.ForeName
AND Pro.Surname = Customer.Surname
AND Pro.CompanyName = Customer.CompanyName

OS

Go to Top of Page

paul.rowling
Yak Posting Veteran

81 Posts

Posted - 2003-04-10 : 08:34:48
Hi Mohdowais,

I think this is what I need, I didn't know that you could join on more than one field.

Thanks

Paul

Go to Top of Page
   

- Advertisement -