pocobueno1388 Posted November 18, 2006 Share Posted November 18, 2006 I have 3 rows in the database that I would like to select...but I would like to select them a certain way.The three rows:[tt]-Agility-Conformation-Speed[/tt]All three of these have integer values.I would like them all added up in the query and them select the rows in order from greatest to least according to their sum.agility + conformation + speedSo I was thinking something like this:mysql_query("SELECT conformation, speed, agility FROM table WHERE conformation + speed + agility > 1 ORDER BY DESC");But I have no idea if that would even be a valid query...I doubt it. Any help on how to put this query together would be greatly appreciated ^^Thank you. Quote Link to comment Share on other sites More sharing options...
lilman Posted November 18, 2006 Share Posted November 18, 2006 mysql_query("SELECT $column_name FROM $table_name ORDER BY $column_name DESC");Fill in the variables with your values, and you should be good. Quote Link to comment Share on other sites More sharing options...
trq Posted November 18, 2006 Share Posted November 18, 2006 Sorry lilman, but did you even read the question?This works in sqlite.[code]SELECT (conformation+speed+agility) AS total FROM tbl ORDER BY total DESC;[/code] Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 18, 2006 Author Share Posted November 18, 2006 Awesome ^^ Thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.