Solved

Query several fields in one table from another table

Posted on 2013-12-03
2
298 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:peternordberg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 500 total points
ID: 39692181
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
 

Author Closing Comment

by:peternordberg
ID: 39692272
Thanks,

just what I needed.

Peter
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question