I’m currently searching for a possibility to order a mysql result by weights that are not part of the result set or the database itself. The only link between the database and the weights is based on one unique column for what the weights exist.
To be more precise i’ve got the MySql table
+-------------------+
|Food |
+-------------------+
|id:int(unique) |
|name:string |
+-------------------+
and one external source of weights for the food ids. For example a user weightens food 1 with 100, food 2 with 200 and food 3 with 50. What i want is to order the result by the weights given by the user.
Do you have any ideas how i can apply these external info into the result?
Edit: I’m not searching for a solution which orders the query result afterwards! I want the result to be ordered by the mysql server.
Here you go :
What you do here is replace your existing row values with your custom values, and then sort it with those values.