mysql - 如何从数据库中按升序获取随机商店名称和价格?

标签 mysql sql database sqlite

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()

最佳答案

试试这个:

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

关于mysql - 如何从数据库中按升序获取随机商店名称和价格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39335400/

相关文章:

Mysql - 获取没有先前状态的行

PHP/MySQL : Access data in Array of Dictionaries

php - 我可以在准备好的语句中参数化表名吗?

mysql - MySQL查询剥离

mysql查询结果。将三列值转换为结果中的一行并按第一列值排序

python - tap-mysql 不返回任何数据

mysql - 如何计算平均时间?

MYSQL Where on DateTime 错误结果

c# - 替代 Group_Concat 以自定义现有 Entity Framework 模型

mysql - 类别属性的数据库模式困惑