mysql随机抽取一条数据

SELECT * FROM pet_diary AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(pet_did) FROM pet_diary)-(SELECT MIN(pet_did) FROM pet_diary))+(SELECT MIN(pet_did) FROM pet_diary)) AS pet_did) AS t2 WHERE t1.pet_did >= t2.pet_did ORDER BY t1.pet_did LIMIT 1;

版主的网址:https://blog.csdn.net/liuxiaojun828/article/details/38703425

猜你喜欢

转载自blog.csdn.net/qq_40694145/article/details/81407760