码迷,mamicode.com
首页 > 数据库 > 详细

历史最长的SQL语句

时间:2016-09-09 18:42:42      阅读:543      评论:0      收藏:0      [点我收藏+]

标签:

 

注释:查询该课程表下,所有的课程以及课程观看的人数统计

SELECT ml.`name` as lessonName,ml.category,ml.deleted,ml.teacherName,
ml.id,ml.liveId,ml.selected,mlc.channelId,p.viewNums,count(*) as totalNum
from mlk_live_channel AS ml 
LEFT JOIN mlk_lesson_channel AS mlc ON mlc.lessonId = ml.id
LEFT JOIN mlk_live_channel AS mcl ON mcl.id = mlc.channelId  
LEFT JOIN 
(SELECT mpr.liveId,mpr.memberId,COUNT(mpr.liveId) as viewNums FROM mlk_payment_record AS mpr 
WHERE mpr.payType = 3 AND mpr.notify = 1 GROUP BY mpr.liveId) AS p 
ON p.liveId = mcl.liveId
WHERE ml.deleted = 0 AND ml.category = 1
GROUP BY ml.id
ORDER BY ml.create_time

 

历史最长的SQL语句

标签:

原文地址:http://www.cnblogs.com/tinywan/p/5857513.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!