I have some code to get a group of results from mysql, please see below,
SELECT string, COUNT(string) as myCount
FROM ip_stats WHERE string != '' OR string IS NOT NULL
GROUP BY string
ORDER BY myCount DESC
LIMIT 10
Now this code works perfectly, however when i add another where clause as below it returns the same results and seems to be completley ignoring the member = section of the where claus?
SELECT string, COUNT(string) as myCount
FROM ip_stats WHERE member_id = '000826' string != '' OR string IS NOT NULL
GROUP BY string
ORDER BY myCount DESC
LIMIT 10
Any ideas or advice is appreciated.
This doesn’t make sense, so I think it may not be what you want:
string IS NOT NULLwill return all non-null values (including ”).I’m guessing that you want to exclude both empty string and null string values, in which case this is probably the query you want: