如何从数据库中提取随机存储名称但价格是否按升序排列?

时间:2016-09-05 17:37:41

标签: mysql sql database sqlite

  

如何通过ASC随机和价格订单使用获取'food_store'订单?   现在写我正在使用此查询

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

1 个答案:

答案 0 :(得分:2)

试试这个:

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