学习是最好的投资!
SELECT *, rand() '_RAND' FROM XXX_TABLE ORDER BY _RAND LIMIT 0,200;使用rand()Generate random number sorting and take out the first 200 items.
SELECT *, rand() '_RAND' FROM XXX_TABLE ORDER BY _RAND LIMIT 0,200;
rand()
Then you choose 200, but it can’t be random. You can use the same idea of paging mysql limit x,x+200 oralce where rownum<x+200 ) where rownum>x;
Try something like this
SELECT * FROM users WHERE userId >= ((SELECT MAX(userId) FROM users)-(SELECT MIN(userId) FROM users)) * RAND() + (SELECT MIN(userId) FROM users) LIMIT 200
SELECT *, rand() '_RAND' FROM XXX_TABLE ORDER BY _RAND LIMIT 0,200;
使用
rand()
Generate random number sorting and take out the first 200 items.Then you choose 200, but it can’t be random. You can use the same idea of paging mysql limit x,x+200 oralce where rownum<x+200 ) where rownum>x;
Try something like this