We have a complex SELECT which is to look at 3 Tables and produce a list of members that have not been contacted about a given subject they are interested in, we have tried this SELECT, it is producing No Errors but produces Zero results:
SELECT swi.email, swd.user_id, swd.category FROM sub_w_dat AS swd
LEFT JOIN sub_we_index AS swi ON (swi.id = swd.ix_id)
LEFT JOIN qa_em_hy AS cc ON (cc.email = swi.email) WHERE swd.category IN (158, 38, 27) AND cc.qa_id = 1399 AND cc.email IS NULL ORDER BY RAND() LIMIT 1000;
If cc.email is null, cc.qa_id will also be null because no record is found on the qa_em_hy table (why do you prefix it as cc if there are no c’s in the table name?).
SELECT swi.email
, swd.user_id
, swd.category
FROM sub_w_dat AS swd
LEFT OUTER
JOIN sub_we_index AS swi
ON swi.id = swd.ix_id
LEFT OUTER
JOIN qa_em_hy AS cc
ON cc.email = swi.email
AND cc.qa_id = 1399
WHERE swd.category IN (158, 38, 27)
AND cc.email IS NULL
ORDER
BY RAND() LIMIT 1000;