MYSQL随机取出20条数据

2025-3-26 / 0 评论 / 5 阅读

SELECT * FROM `table`
WHERE id >= (SELECT floor( RAND() * ((SELECT MAX(id) FROM `table`)-(SELECT MIN(id) FROM `table`)) + (SELECT MIN(id) FROM `table`))) dtTime > '2013-05-11'
ORDER BY id LIMIT 20;