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
Solved

SQL Select where not exists?

Posted on 2012-12-26
2
597 Views
Last Modified: 2012-12-26
(Simplified)
I have a view with the following 4 fields

ClientID   ContactID    ContactType   FullName


I want to do a UNION all and
Select  ClientID, ContactID,ContactType,FullName
From ClientContacts

Where the ClientCOntacts record doesn't exist in the View

The similar fields are of course ClientID and ContactID
0
Comment
Question by:lrbrister
2 Comments
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 500 total points
ID: 38722275
select  ClientID, ContactID, ContactType, FullName
from ClientContactsView C
union all
select  ClientID, ContactID, ContactType, FullName
from ClientContacts C
where not exists (
  select 1
  from ClientContactsView C1
  where C.ClientID = C1.ClientID and C.ContactID = C1.ContactID
)

Open in new window

0
 

Author Closing Comment

by:lrbrister
ID: 38722296
Thanks
Buried and can't remember the simplest thing
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

860 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