I need to sort the result of my search by a value that is outside the query.
For example, in the query I have a field called response and with this value I make a calculation. But the result of this calculation is not in table.
My query
$search = mysql_query('SELECT * FROM simuladosrespondidos AS sr
JOIN usuarios AS u ON u.idUsuarios = '.$idUsuario.' AND sr.idUsuarios = u.idUsuarios
JOIN questoes AS q ON q.idQuestao = sr.idQuestao WHERE sr.idSimulado = '.$idSimulado.'');
What I do is take the value of a column called answers and do the calculation on top of it. How to sort by this calculation?
Note: The calculation that I actually do is the following: I get the value of the answer column. Each user has several answers. If it is equal to 'C' + 1 in a variable here. If it is equal to 'E' it decreases - 1 and if it is equal to And I do nothing and at the end of everything I have a value and it is by that value that I want to sort.