If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > NOT EXIST Is there another way?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-01-07, 12:19
mlong30 mlong30 is offline
Registered User
 
Join Date: Oct 2007
Posts: 13
NOT EXIST Is there another way?

Hi All,

I want to join two tables, and display data results only if the record doesn't exist or meet the conditions. The only way I know how to do this is to use a NOT EXIST statement. Are there other options?

USE pub
SELECT *
FROM authors u
WHERE NOT EXISTS (SELECT 1 FROM titleauthor WHERE au_id = u.au_id)

Thanks.

Matt
Reply With Quote
  #2 (permalink)  
Old 11-01-07, 12:29
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Code:
SELECT u.something
     , u.anything
     , u.just_not_the_dreaded_evil_select_star 
  FROM authors AS u
LEFT OUTER
  JOIN titleauthor AS a
    ON a.au_id = u.au_id
 WHERE a.au_id IS NULL
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On