如何使用mysql在运算符之间通过随机函数添加顺序?

时间:2017-11-13 08:02:13

标签: mysql

SQL查询:

SELECT *
FROM Products
WHERE ProductName BETWEEN 'Carnarvon Tigers' AND 'Mozzarella di Giovanni'
ORDER BY ProductID;

1 个答案:

答案 0 :(得分:0)

MySQL有一个rand函数,它返回一个0到1之间的随机数。你可以按顺序排序:

SELECT   *
FROM     Products
WHERE    ProductName BETWEEN 'Carnarvon Tigers' AND 'Mozzarella di Giovanni'
ORDER BY RAND();