随机取数据
SELECT * FROM tablename ORDER BY RAND() LIMIT 1
SELECT *
- FROM table_name AS r1 JOIN
- (SELECT ROUND(RAND() *
- (SELECT MAX(id)
- FROM table_name)) AS id)
- AS r2
- WHERE r1.id >= r2.id
- ORDER BY r1.id ASC
- LIMIT 5;
select *, rand() as random from 'table' order by random limit 1