I have a statistics database for people who have visited. This table contains ID, timestamp IPv4, IPv6, User Agent and REQUEST_URI. I get false numbers by running something like
SELECT COUNT(DISTINCT IPv4) AS 'Uniques', COUNT(*) AS 'Total' FROM statistics
So I need to filter out the bots from humans. My approach is this:
SELECT ID FROM statistics WHERE NOT EXISTS(SELECT ID FROM statistics WHERE useragent NOT LIKE '%bot%')
This should select all rows from statistics which are not present in the query which searches for non-bots. I think the query looks reasonable so why isn’t it working?
And there is a reason I want to do it this way instead of
SELECT ID FROM statistics WHERE useragent LIKE '%bot%'
Any ideas?
I’m a bit confused, but maybe you want to do: