I have a select statement that tries to find how many ip came back today, that also visited this month, but it's not working for some reason. What am I doing wrong?
SELECT ip, COUNT( ip ) AS matches, DATE AS tempDate
WHERE YEAR( DATE ) = '2015'
AND MONTH( DATE ) = '12'
GROUP BY ip
HAVING matches > 1
AND tempDate = '2015-12-29'
LIMIT 0 , 30
For it to return one or more rows.
It returned 0 rows
date is a column name, and yes, I am sure that there 2 or more ips in the database in the same year, month and day.
Perfectly works for me:
SELECT ip, COUNT( ip ) AS matches, DATE AS tempDate FROM ipAll WHERE DATE_FORMAT(DATE,'%Y-%m') = DATE_FORMAT(NOW(),'%Y-%m') GROUP BY ip HAVING matches > 1 LIMIT 0 , 30
NOTE that DATE column is a MySQL Keyword you should replace the column name with a different one