Query several fields in one table from another table

Hi,

I have a table looking like this:
customerID int
firstname
lastname
address
zip
city

Then I have a second table looking like this:
id
name (Smith, John)
adress
zip
city

what I need to do is to get all records from the first table that are not part of the second one based on firstname, lastname and city. The name is stored in a firstname and a lastname in the first but they are in one column in the second.

How can I accomplish this in a query?

Peter
peternordbergAsked:
Who is Participating?
 
Ephraim WangoyaConnect With a Mentor Commented:
select * from firsttable A
where not exists(select 1 from secondtable B
           where A.lastname + ', ' + A.firstname = B.name
           and A.city = B.city)
0
 
peternordbergAuthor Commented:
Thanks,

just what I needed.

Peter
0
All Courses

From novice to tech pro — start learning today.