MYSQL随机抽取数据库里的几条数据
时间:2007-02-18 来源:PHP爱好者
mysql> use discuz;
Database changed
mysql> select username from cdb_members order by rand() limit 0,5;
+--------------+
| username |
+--------------+
| hahamimi |
| hyp323 |
| zjh00958 |
| 梦有知 |
| winteralways |
+--------------+
5 rows in set (0.03 sec)
mysql> select username from cdb_members order by rand() limit 0,5;
+-----------+
| username |
+-----------+
| setnm2003 |
| Raymond |
| nyyjy010 |
| 290500231 |
| samtian |
+-----------+
5 rows in set (0.00 sec)
mysql> select username from cdb_members order by rand() limit 0,5;
+-------------+
| username |
+-------------+
| ly2008 |
| tellgkkg |
| 1502050124 |
| powershot |
| adriftcloud |
+-------------+
5 rows in set (0.00 sec)
mysql> select username from cdb_members order by rand() limit 0,5;
+-----------+
| username |
+-----------+
| Takeshi |
| icelong |
| 狗狗请罪 |
| 菜头 |
| weike1130 |
+-----------+
5 rows in set (0.01 sec)
mysql> select username from cdb_members order by rand() limit 0,5;
+----------+
| username |
+----------+
| 菜头 |
| romeoqq |
| hahamimi |
| 青玫瑰 |
| lmhllr |
+----------+
5 rows in set (0.00 sec)
mysql>
Database changed
mysql> select username from cdb_members order by rand() limit 0,5;
+--------------+
| username |
+--------------+
| hahamimi |
| hyp323 |
| zjh00958 |
| 梦有知 |
| winteralways |
+--------------+
5 rows in set (0.03 sec)
mysql> select username from cdb_members order by rand() limit 0,5;
+-----------+
| username |
+-----------+
| setnm2003 |
| Raymond |
| nyyjy010 |
| 290500231 |
| samtian |
+-----------+
5 rows in set (0.00 sec)
mysql> select username from cdb_members order by rand() limit 0,5;
+-------------+
| username |
+-------------+
| ly2008 |
| tellgkkg |
| 1502050124 |
| powershot |
| adriftcloud |
+-------------+
5 rows in set (0.00 sec)
mysql> select username from cdb_members order by rand() limit 0,5;
+-----------+
| username |
+-----------+
| Takeshi |
| icelong |
| 狗狗请罪 |
| 菜头 |
| weike1130 |
+-----------+
5 rows in set (0.01 sec)
mysql> select username from cdb_members order by rand() limit 0,5;
+----------+
| username |
+----------+
| 菜头 |
| romeoqq |
| hahamimi |
| 青玫瑰 |
| lmhllr |
+----------+
5 rows in set (0.00 sec)
mysql>
相关阅读 更多 +