Utkarsh Sharma Utkarsh Sharma - 9 months ago 37
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()


Try this:

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