Solved

SQL Select where not exists?

Posted on 2012-12-26
2
594 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
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.

777 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