Friday 5 October 2012

SQL Query: Select only values from one table that do not exist in another table

Scenario:
I want to select some record from table2 when it is not exist in table1

Solution:
SELECT
  table2.column_name
FROM
    table1
  LEFT JOIN
    table2
  ON
    table1.id = table2.id
WHERE
  table1.id IS NULL

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home