MySQL - Conflicting WHERE and GROUP BY Statements
- by TaylorPLM
I have a query returning the counts of some data, but I do NOT want data that has a null value in it...
As an example, the code rolls stats from a clicking system into a table.
SELECT sh.dropid, ...
FROM subscriberhistory sh
INNER JOIN subscriberhistory sh2 on sh.subid = sh2.subid
WHERE sh.dropid IS NOT NULL
AND sh.dropid != "" ...
GROUP BY sh.dropid
An example of the record set returned would look like this...
400 2 3 4 5 6
401 2 3 6 5 4
NULL 2 3 4 5 1
There are some other where clauses, and a few more selects (as I said, using the count aggregate) that are also within the query. There is also an order by statement.
Again, the goal is to keep the NULL data out of the preceding record set. Could someone explain to me why this behavior is occurring and what to do to solve it.