长sql优化

This commit is contained in:
张松 2025-01-02 16:36:12 +08:00
parent cf2f17acc1
commit bdc050ea1e
1 changed files with 20 additions and 35 deletions

View File

@ -8,46 +8,31 @@
</update>
<select id="selectCourse" resultType="Map">
SELECT
c.classify_id as classifyId,
c.course_id as courseId,
c.course_label as courseLabel,
c.create_time createTime,
c.classify_id AS classifyId,
c.course_id AS courseId,
c.course_label AS courseLabel,
c.create_time AS createTime,
c.details,
c.img,
c.banner_img as bannerImg,
c.banner_img AS bannerImg,
c.status,
c.is_delete as isDelete,
c.msg_type msgType,
c.msg_url as msgUrl,
c.pay_num as payNum,
c.is_delete AS isDelete,
c.msg_type AS msgType,
c.msg_url AS msgUrl,
c.pay_num AS payNum,
c.price,
c.wholesale_price as wholesalePrice,
c.is_over as isOver,
c.wholesale_price AS wholesalePrice,
c.is_over AS isOver,
c.title,
c.is_price as isPrice,
c.title_img as titleImg,
c.update_time as updateTime,
cc.classification_name as classificationName,
c.course_type as courseType,
c.banner_id as bannerId,
b.name as bannerName,
0 as viewCounts,
c.dy_img_id as dyImgId,
c.dy_course_id as dyCourseId,
c.wx_course_id as wxCourseId,
c.wx_show as wxShow,
c.dy_show as dyShow,
c.sort,
round(10000*rand(),0) as goodNum,
ifnull(d.courseDetailsCount,0) as courseDetailsCount,
null AS courseDetailsName,
null AS courseDetailsId,
round(10000*rand(),0) as weekGoodNum,
0 as isRecommend
c.is_price AS isPrice,
c.title_img AS titleImg,
c.update_time AS updateTime,
c.course_type AS courseType,
c.banner_id AS bannerId,
COALESCE(d.courseDetailsCount, 0) AS courseDetailsCount
FROM
course AS c
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id
LEFT JOIN banner AS b ON b.id = c.banner_id
LEFT JOIN (
SELECT
course_id,
@ -58,8 +43,8 @@
course_id
) AS d ON d.course_id = c.course_id
WHERE
1 = 1
AND c.is_delete = 0
c.is_delete = 0
<if test='null != wxShow and wxShow==1'>
and c.wx_show = #{wxShow}
</if>