sql中in查询的查询速率很慢,我们可以做成左关联查询,提高查询速率
SELECT a.icon_id,count(a.icon_id) as relationCount,d.title as relationWord FROM speak_user_icon a
left join ( SELECT *,count(works_id) from speak_user_icon where
1=1
group by works_id) b on a.works_id = b.works_id left join speak_icon d on a.icon_id =d.id
where a.works_id = b.works_id and
1=1
group by a.icon_id
order by relationCount desc,a.create_time desc
sql中in查询改为关联查询
最新推荐文章于 2024-06-04 09:06:32 发布