So I have a left join going on, and my where clause has a field does not equal value on one of the fields in the table which is left joined.
So the problem is, if the left join returns no rows, then the where clause is automatically failing (even though it doesn't equal) so the row doesn't show up... so basically what I want is, if LEFT JOIN fails on this table or the where clause evaluates to true, then do it.
Perhaps an example will help
Table a: id, name
Table b: id, sex
SELECT a.id, a.name, b.sex
FROM a
LEFT JOIN ON a.id=b.id
WHERE a.id > 5
AND b.sex != 'male'
So I want everyone I can't prove is male, that is both people who are female, and people who have no entry in the b table.
So the problem is, if the left join returns no rows, then the where clause is automatically failing (even though it doesn't equal) so the row doesn't show up... so basically what I want is, if LEFT JOIN fails on this table or the where clause evaluates to true, then do it.
Perhaps an example will help
Table a: id, name
Table b: id, sex
SELECT a.id, a.name, b.sex
FROM a
LEFT JOIN ON a.id=b.id
WHERE a.id > 5
AND b.sex != 'male'
So I want everyone I can't prove is male, that is both people who are female, and people who have no entry in the b table.