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. Link to comment https://forums.phpfreaks.com/topic/27646-how-would-i-make-a-select-query-like-this/ 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. Link to comment https://forums.phpfreaks.com/topic/27646-how-would-i-make-a-select-query-like-this/#findComment-126468 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] Link to comment https://forums.phpfreaks.com/topic/27646-how-would-i-make-a-select-query-like-this/#findComment-126472 Share on other sites More sharing options...
pocobueno1388 Posted November 18, 2006 Author Share Posted November 18, 2006 Awesome ^^ Thank you very much. Link to comment https://forums.phpfreaks.com/topic/27646-how-would-i-make-a-select-query-like-this/#findComment-126475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.