帝国CMS MYSQL随机调用速度比拼及方法 

第一种

select a.* from phome_ecms_news a join (select round((select max(id) from phome_ecms_news) * rand()) as rid from phome_ecms_news limit 10) b where a.id = b.rid

第二种

select * from phome_ecms_news where rand()<0.015 limit 10

第三种

$sql=$empire->query("SELECT * FROM {$dbtbpre}ecms_news WHERE id >= ((SELECT MAX(id) FROM {$dbtbpre}ecms_news)-(SELECT MIN(id) FROM {$dbtbpre}ecms_news)) * RAND() + (SELECT MIN(id) FROM {$dbtbpre}ecms_news) ORDER BY id limit 10");

第四种

只适合在内容页模板调用

select * from {$dbtbpre}ecms_news where classid='$navinfor[classid]' and  id>'$navinfor[id]'-1000 and id<'$navinfor[id]'+1000 order by rand() limit 10

第五种

select * from {$dbtbpre}ecms_news order by rand() limit 10

声明:有的资源均来自网络转载,版权归原作者所有,如有侵犯到您的权益 请联系邮箱:123456@qq.com 我们将配合处理!

原文地址:帝国CMS MYSQL随机调用速度比拼及方法发布于2024-08-24 10:06:35

相关推荐