I have this database with a table and a row called ‘rank’.
In that database table there are 2 teams. Each Get ranked every day.
Ex.
Day 1.
Team F – rank =1
Team R – rank =2
Day 2.
Team R – rank =1
Team F – rank =2
So i want the teams to appear on top because of their higher rank
Right now I got this: (appear as entered)-while($person = mysql_fetch_array($result)) {
So what do I put in that code in order to make it be the highest value of a column.
any ideas?
Could you be more specific about your table layout? Maybe provide the
CREATE TABLESQL that was used to create it?To order results by value, you can end a sql query with
ORDER BY column_name DESCin order to get the results returned in MAX -> MIN order of that column. You can replaceDESCwithASCto get it to go in MIN -> MAX order. If you don’t putDESCorASCit defaults to one of them, but I forget which.If you want to sort on more than one column, put them in the
ORDER BYas comma separated. SoORDER BY column1, column2 DESCwill produce a listing that is ordered from the greatest value ofcolumn1to the least value, and anytime the values ofcolumn1are identical between rows, it will orders those bycolumn2.If I read your question correctly, and you in fact have a “row” named rank, then something is wrong with your table structure, as you can’t really name “rows” (and SQL generally refers to rows as records, anyway).