且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 MySQL 中选择随机行

更新时间:2023-02-07 14:15:46

您可以使用 rand 函数在 MySQL 中对行进行排序,然后使用 limit 取前 10 个(或您想要的任何数量).

You can use the rand function in MySQL to order the rows, and then take the top 10 (or however many you want) with limit.

select * from table order by rand() limit 10

如果你只想要数学题:

select * from table where type = 1 order by rand() limit 10