mysql随机返回一条数据
作者:互联网
select * from biz_question ORDER BY RAND(id) LIMIT 1;
SELECT * FROM biz_question AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM biz_question)-(SELECT MIN(id) FROM biz_question))+(SELECT MIN(id) FROM biz_question)) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id LIMIT 1
建议第二种,效率高一些
标签:返回,RAND,question,t1,biz,随机,mysql,id,SELECT 来源: https://www.cnblogs.com/liaozk/p/16521660.html