长sql优化
This commit is contained in:
@@ -8,46 +8,31 @@
|
|||||||
</update>
|
</update>
|
||||||
<select id="selectCourse" resultType="Map">
|
<select id="selectCourse" resultType="Map">
|
||||||
SELECT
|
SELECT
|
||||||
c.classify_id as classifyId,
|
c.classify_id AS classifyId,
|
||||||
c.course_id as courseId,
|
c.course_id AS courseId,
|
||||||
c.course_label as courseLabel,
|
c.course_label AS courseLabel,
|
||||||
c.create_time createTime,
|
c.create_time AS createTime,
|
||||||
c.details,
|
c.details,
|
||||||
c.img,
|
c.img,
|
||||||
c.banner_img as bannerImg,
|
c.banner_img AS bannerImg,
|
||||||
c.status,
|
c.status,
|
||||||
c.is_delete as isDelete,
|
c.is_delete AS isDelete,
|
||||||
c.msg_type msgType,
|
c.msg_type AS msgType,
|
||||||
c.msg_url as msgUrl,
|
c.msg_url AS msgUrl,
|
||||||
c.pay_num as payNum,
|
c.pay_num AS payNum,
|
||||||
c.price,
|
c.price,
|
||||||
c.wholesale_price as wholesalePrice,
|
c.wholesale_price AS wholesalePrice,
|
||||||
c.is_over as isOver,
|
c.is_over AS isOver,
|
||||||
c.title,
|
c.title,
|
||||||
c.is_price as isPrice,
|
c.is_price AS isPrice,
|
||||||
c.title_img as titleImg,
|
c.title_img AS titleImg,
|
||||||
c.update_time as updateTime,
|
c.update_time AS updateTime,
|
||||||
cc.classification_name as classificationName,
|
c.course_type AS courseType,
|
||||||
c.course_type as courseType,
|
c.banner_id AS bannerId,
|
||||||
c.banner_id as bannerId,
|
COALESCE(d.courseDetailsCount, 0) AS courseDetailsCount
|
||||||
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
|
|
||||||
FROM
|
FROM
|
||||||
course AS c
|
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 (
|
LEFT JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
course_id,
|
course_id,
|
||||||
@@ -58,8 +43,8 @@
|
|||||||
course_id
|
course_id
|
||||||
) AS d ON d.course_id = c.course_id
|
) AS d ON d.course_id = c.course_id
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
c.is_delete = 0
|
||||||
AND c.is_delete = 0
|
|
||||||
<if test='null != wxShow and wxShow==1'>
|
<if test='null != wxShow and wxShow==1'>
|
||||||
and c.wx_show = #{wxShow}
|
and c.wx_show = #{wxShow}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user