Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2007
    Posts
    25

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •