[MySql] Order from Highest to Lowest Number [RESOLVED]
Posted: Mon Jul 12, 2010 1:30 pm
Hi guys,
I have a PHP that queries a database, counts specific errors and then outputs a count of all errors to the screen, but this list is not ordered from Highest to lowest count on the output.
I use this code to count the amount of each error from the DB.
Can anyone help me to add the Mysql command that will sort the error count from highest to lowest?
Example:
If total errors were -> Error 4444 = 30, Error 5555 = 60, Error 6666 = 3. I want the output to look like this:
Error 5555 = 60
Error 4444 = 30
Error 6666 = 3
Currently it looks like this:
Error 4444 = 30
Error 5555 = 60
Error 6666 = 3
Any help would be greatly appreciated.
Thanks
I have a PHP that queries a database, counts specific errors and then outputs a count of all errors to the screen, but this list is not ordered from Highest to lowest count on the output.
I use this code to count the amount of each error from the DB.
Code: Select all
$query = "select '4444' as 'error', count(*) as 'total' from table where desc like '%error: 4444%'
union select '5555' as 'error', count(*) as 'total' from logs where desc like '%error: 5555%'
union select '6666' as 'error', count(*) as 'total' from logs where desc like '%error: 6666%'Example:
If total errors were -> Error 4444 = 30, Error 5555 = 60, Error 6666 = 3. I want the output to look like this:
Error 5555 = 60
Error 4444 = 30
Error 6666 = 3
Currently it looks like this:
Error 4444 = 30
Error 5555 = 60
Error 6666 = 3
Any help would be greatly appreciated.
Thanks