mysql随机获取10条数据

mysql随机获取10条数据

{{ detail.nickname }}

{{ formatTime(detail.create_time) }} 字数 {{ detail.content && detail.content.length }} 阅读 {{ detail.read_num }}

"假如表名为:user\n\n## 方式一\n\n```sql\nSELECT * FROM user ORDER BY RAND() LIMIT 10;\n```\n\n## 方式二\n\n```sql\nSELECT * FROM user  WHERE id>=((SELECT MAX(id) FROM user)-(SELECT MIN(id) FROM user))*RAND()+(SELECT MIN(id) FROM user) LIMIT 10;\n```"
PS:写作不易,如要转裁,请标明转载出处。

如果此篇对您有帮助,可小额赞助,以兹鼓励!