user6835647 user6835647 - 1 year ago 68
MySQL Question

SQL Query to display records not in the condition

I am having trouble on how to display records who are not equal on b.sponsor_id=s.sponsor_id. Please help!

Answer Source

Your question sounds like you want to join the tables whose aliases are b and s on some condition, and retain records which do not match. If you wanted to retain records from b which do not match, then you can try using a LEFT JOIN instead of an INNER JOIN:

FROM tableB b
LEFT JOIN tableS s
    ON b.sponsor_id = s.sponsor_id
WHERE s.sponsor_id IS NULL
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download