I am trying to count the number of rows whose date has not yet passed so i can get only the current records
I get an error sayng
MySQL error #111 Invalid use of group function
SELECT COUNT(festivalid) FROM festivals WHERE min(datefrom) > now()
I am trying to count the number of rows whose date has not yet passed so i can get only the current records
I get an error sayng
MySQL error #111 Invalid use of group function
SELECT COUNT(festivalid) FROM festivals WHERE min(datefrom) > now()
The reason for the error is that you can not use aggregate (IE: MIN, MAX, COUNT...) functions in the
WHEREclause - only in theHAVINGclause can you do this. And to define theHAVINGclause, your query needs to have aGROUP BYclause defined:...but I have my doubts about the query, and think it would be better to use:
CURRENT_TIMESTAMPis ANSI standard equivalent to MySQL specificNOW(), making the query portable to other databases.