dsaba Posted June 3, 2007 Share Posted June 3, 2007 I know this has to do with group by syntax, but its giving me errors $mostever_query = mysql_query("SELECT * COUNT(*) as howmany FROM online GROUP BY date WHERE url='$url' ORDER BY howmany DESC LIMIT 0, 1") or die(mysql_error()); I have a table called 'online' i have 2 fields called 'date' and 'url' All I want to do is find the date that occurs the most in the 'online' table where url='$url' and get a number of how many times it occurs in the table How can I do this? What am I doing wrong in my query? it errors like this: (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COUNT(*) as howmany FROM online GROUP BY date WHERE url='/p2m-tr) thanks Link to comment https://forums.phpfreaks.com/topic/54072-solved-using-group-by-syntax-in-mysql_query/ Share on other sites More sharing options...
dsaba Posted June 3, 2007 Author Share Posted June 3, 2007 solved: "SELECT *, COUNT(*) as howmany FROM online WHERE url = '$url' GROUP BY date ORDER BY howmany DESC LIMIT 1" Link to comment https://forums.phpfreaks.com/topic/54072-solved-using-group-by-syntax-in-mysql_query/#findComment-267321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.