John Mistler wrote:
I have two tables 'table1', 'table2' with a matching column 'column1'. How can I return all rows from table2 where the entry for table2.column1 does not match any entries in table1.column1?

SELECT * FROM table2 WHERE table2.column1 <> table1.column1

returns all the rows, rather than the unique rows in table2 ... Any ideas?

Thanks,

John

You need a LEFT JOIN:

  SELECT table2.*
  FROM table2
  LEFT JOIN table1 ON table1.column1 = table2.column1
  WHERE table1.column1 IS NULL;

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to