How to compare two columns to find unmatched records. Help Please

I have a table with 2 columns and each column has thousands of records

For Example 15000 Email addresses in Column1 and 15005 Email addresses in column 2

How to find those 5 records from 15005 which are unmatched in column1?

I wish MySql query to compare both columns and give result of only 5 unmatched records

Thanks

could you please do a SHOW CREATE TABLE for this table, and give a few rows of sample data

Hi,

Here’s SHOW CREATE Table and sample data

CREATE TABLE emailtry (
id INT(11) NOT NULL AUTO_INCREMENT,
email1 VARCHAR(100) DEFAULT NULL,
email2 VARCHAR(100) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=MYISAM AUTO_INCREMENT=65633 DEFAULT CHARSET=latin1


email1	                     email2
----------------------------------------------
test0@example.com	     test0@example.com
test1@example.com	     test1@example.com
test2@example.com	     test2@example.com
test3@example.com	     test3@example.com
test4@example.com	     abc@example.com
test5@example.com	     test5@example.com

The second last is different and I wish query to list only those rows that do not match.

Thanks

i was hoping to see one of the rows that was missing an email column value :slight_smile:

anyhow, try this –


SELECT email1
     , email2
  FROM emailtry
 WHERE email1 <> email2

WOW ! This works Great ! When you only have time for answers ! Thank you so very much.

With Warm Regards