试试这个:
mysql> create table t (i int);
mysql> insert into t values (1),(2),(3),(4),(5),(6);
mysql> select * from t order by rand(123) limit 2 offset 0;
+------+
| i |
+------+
| 6 |
| 4 |
+------+
mysql> select * from t order by rand(123) limit 2 offset 2;
+------+
| i |
+------+
| 2 |
| 3 |
+------+
mysql> select * from t order by rand(123) limit 2 offset 4;
+------+
| i |
+------+
| 5 |
| 1 |
+------+
请注意,rand()函数具有种子值(123).另请注意,如果重复最后三个查询,则每次都会得到相同的结果.