SQL beginner here, trying to figure out how I can grab both NULL and NOT NULL values from a table in MySQL. I've tried omitting specifying null and not null to see if that would grab both types, but no luck.
SELECT
COUNT('') as cnt
FROM returned_items ri
LEFT JOIN returns r ON ri.return_id = r.return_id
WHERE r.storenum IN (11)
With NULL and NOT NULL:
SELECT
COUNT('') as cnt
FROM returned_items ri
LEFT JOIN returns r ON ri.return_id = r.return_id
WHERE r.storenum IN (11)
AND ri.disposition is NULL AND NOT NULL
Any advice is greatly appreciated.
LEFT JOIN, conditions on the second table should normally be in theONclause, notWHERE. Otherwise, it will filter out any rows in the first table that have no match, becauser.storenumwill beNULLin those rows. So it becomes effectively the same asINNER JOIN.ri.disposition, so it should return both null and non-null values.