I have three tables:
The first two tables contain data for demo users. The third table contains data for demo users who have purchased.
What I'd like to do is return the firstname, lastname, email for all users in the first two tables whose email doesn't show up in the third table.
The SQL query I wrote looks like this:
SELECT DISTINCT firstname AS firstname, lastname AS lastname, email FROM uga_comment WHERE email NOT IN (SELECT DISTINCT email FROM ecom_customers)
UNION ALL SELECT DISTINCT fname AS firstname, lname AS lastname, email FROM cfp_demo
WHERE email NOT IN (SELECT DISTINCT email FROM ecom_customers) ORDER BY lastname ASC
Before I added the WHERE email NOT IN () part to both parts of the UNION it was returning the correct number of records. Trying to compare them screwed it up. My lack of knowledge screwed them up. :-)
Any pointers for correcting this issue?