Try: SELECT string, COUNT(string) AS length FROM searchstat GROUP BY string ORDER BY length
You can DESC at the end if you want the longest string first. Cheers, Paul [EMAIL PROTECTED] tel: 020 7446 7536 fax: 0207 833 4289 <http://videoisland.com/> - The UK's ultimate DVD library :-----Original Message----- :From: Dialogcentret [mailto:[EMAIL PROTECTED] :Sent: 27 August 2004 14:04 :To: [EMAIL PROTECTED] :Subject: Sort by COUNT(field_name) ? : :Example: I have a search box on my webpage and all :searchstring are saved in a database. : :$foresp = mysql_query("SELECT string, COUNT(string) FROM :searchstat GROUP BY string ",$db); : :while ($data = mysql_fetch_array($foresp)) { echo :"<br>($data[1]) " . str_replace('<', '<', $data[string]) . " "; } : :However, I would like to write the result out with the most :popular search strings first. Is it possible to sort the :output by count(field_name) ? : : : :Med venlig hilsen :Birger Langkjer :Dialogcentret : -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]