SQL Select where not exists?

Larry Brister
Larry Brister used Ask the Experts™
on
(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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Director
Commented:
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

Larry Bristersr. Developer

Author

Commented:
Thanks
Buried and can't remember the simplest thing

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial