How can I order the following query through 2 different variables of the same table, so that it is from highest to lowest:
I have the following query:
$sql2="select * from detalle_fac, precios where fk_factura='$factura' and detalle_fac.fk_producto=precios.id_pre ORDER BY precios.tamano_one DESC";
That query is ordered by the variable: prices.size_one but I also need to order it by another variable, which would be the following:
prices.size_two
from highest to lowest, that is, the first order would be size_one and the second order would be size_two, how can I do it?
My query ordered by the variable size_one returns the following:
VARIABLES:
So the idea is that it is sorted by size_one from largest to smallest and likewise by size_two from largest to smallest.
OK, complementing fernando's answer, this is how my query is with fernando's answer:
You can use different orders between fields of the same table.
In the end this would be ordering like this:
This query will first sort your results by field
precios.tamano_one
descending, then it will sort by fieldprecios.tamano_two
descendingDESC
(highest to lowest)I leave you this page as a reference so you can learn more about how to order by one or more fields.