Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2014
    Posts
    1

    Unanswered: New To Databases

    So say I run an left join on two tables. How do I display what was not selected in the query?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    [quote]How do I display what was not selected in the query]/quote]
    what do you mean by that, then?

    a left join mean return all rows from the left table and those rows from the right table that match
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    All those in first_table that do not have a match in other_table:
    Code:
    FROM   first_table
     LEFT
      JOIN other_table
        ON other_table.field = first_table.field
    WHERE  other_table.field IS NULL
    Alternatively you may wish to learn about the EXISTS clause
    Code:
    FROM   first_table
    WHERE  NOT EXISTS (
             SELECT field
             FROM   other_table
             WHERE  field = first_table.field
           )
    George
    Home | Blog

Tags for this Thread

Posting Permissions

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