MySQL PHP order by -
i'm writing mysql query sort kind of data
traffic 100/40 12/1 50/20 25/5
the value devide right hand side number left hand side number.
also have multi columns sort
ex - select * fltable order traffic desc,speed asc,cost asc
i need sort data ascending order , descending order, can me this.
thank you
select * fractions; +-----------+ | fractions | +-----------+ | 100/40 | | 12/1 | | 25/5 | | 50/20 | +-----------+ select fractions , substring_index(fractions,'/',1)/substring_index(fractions,'/',-1)x fractions order x desc; +-----------+------+ | fractions | x | +-----------+------+ | 12/1 | 12 | | 25/5 | 5 | | 100/40 | 2.5 | | 50/20 | 2.5 | +-----------+------+
Comments
Post a Comment