'$times' GROUP BY us">
当前位置:Gxlcms > PHP教程 > mysql随机获取优化话语

mysql随机获取优化话语

时间:2021-07-01 10:21:17 帮助过:3人阅读

mysql随机获取优化语句
在网上找了一个随机取数语句,结合了自己的需求,运行出错,
看了半天没发现出错的地方,求指点

$str="select * from dizhi where shijiancuo>'$times' GROUP BY user HAVING COUNT(user) > 4 AS t1
JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM dizhi)) AS id) AS t2
WHERE t1.id >= t2.id
ORDER BY t1.id ASC LIMIT 1" ;



select * from
(select * from dizhi where shijiancuo>'$times' GROUP BY user HAVING COUNT(user) > 4) AS t1
JOIN
(SELECT ROUND(RAND() * (SELECT MAX(id) FROM dizhi)) AS id) AS t2
WHERE t1.id >= t2.id
ORDER BY t1.id ASC LIMIT 1

人气教程排行