从mysql数据表中随机取出一条记录
效率极差的一种办法:select * from 表名 order by rand( ) limit 1; //此处的1就是取出数据的条数高效写法SELECT * FROM user WHERE userId >= ((SELECT MAX(userId) FROM user )-(SELECT MIN(userId) FROM user )) * RAND() + (S
·
效率极差的一种办法:
select * from 表名 order by rand( ) limit 1; //此处的1就是取出数据的条数
高效写法
SELECT * FROM user WHERE userId >= ((SELECT MAX(userId) FROM user )-(SELECT MIN(userId) FROM user )) * RAND() + (SELECT MIN(userId) FROM user ) LIMIT 5
select * from 表名 order by rand( ) limit 1; //此处的1就是取出数据的条数
高效写法
SELECT * FROM user WHERE userId >= ((SELECT MAX(userId) FROM user )-(SELECT MIN(userId) FROM user )) * RAND() + (SELECT MIN(userId) FROM user ) LIMIT 5
更多推荐
已为社区贡献1条内容
所有评论(0)