Utkarsh Sharma Utkarsh Sharma - 1 year ago 67
MySQL Question

how to fetch random stores name but price in ascending order from database?

how to use fetch 'food_store' order by randomly and price order by ASC ?
write now i am using this query

Select * from `food` where `veg_non` = 'Veg' and `food_price` <= ? ORDER BY RAND()

Answer Source

Try this:

Select *, RAND() as r from `food` where `veg_non` = 'Veg'
    and `food_price` <= ? ORDER BY `food_price` ASC, r ASC
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download