gpt4 book ai didi

php - 如何使这个查询运行得更快

转载 作者:可可西里 更新时间:2023-11-01 07:58:46 24 4
gpt4 key购买 nike

我想知道这个查询是否可以运行得更快或者如果可能的话如何让它更快。

$result = mysql_query("select
(select count(1) FROM videos WHERE title LIKE '%Cars%')as Cars,
(select count(1) FROM videos WHERE title LIKE '%Bikes%') as 'Bikes',
(select count(1) FROM videos WHERE title LIKE '%Airplanes%') as 'Airplanes',
(select count(1) FROM videos WHERE title LIKE '%Trucks%') as 'Trucks',
(select count(1) FROM videos WHERE title LIKE '%Games%') as 'Games'");

$row = mysql_fetch_assoc($result);

foreach($row as $title => $total)
{
echo '<li>
<a href="search.php?search='. $title . '&submit= ">'. $title.'&nbsp;&nbsp;'. $total .'</a></li>';
}

echo '<li class="spaceIN"></li><li class="letter">A</li>';

我复制了这个脚本并粘贴了大约 100 次,这样做之后加载速度真的很慢。

最佳答案

像这样

select sum(title LIKE '%Cars%') as cars,
sum(title LIKE '%Bikes%') as bikes
from videos

关于php - 如何使这个查询运行得更快,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26195308/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com