码迷,mamicode.com
首页 > 其他好文 > 详细

把查询到结果合并放在一行 JOIN非union

时间:2016-01-08 23:21:22      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

select one.max,one.min,one.low sts,c.high ens,one.time from (

        select a.max max,a.min min,b.low low,a.time time,a.aid aid from

        (select max(price) max,min(price) min,time time,id aid from on_jiaoyi_into where sid=".$id."
        group by DATE_FORMAT(`time`,%Y-%m-%d) ) a LEFT JOIN

        (select price low,id bid from on_jiaoyi_into where sid=".$id."
        group by DATE_FORMAT(`time`,%Y-%m-%d)  
        order by time ) b on a.aid=b.bid 

        ) one LEFT JOIN

        (select price high,id cid from on_jiaoyi_into where sid=".$id."
        group by DATE_FORMAT(`time`,%Y-%m-%d)  
        order by time desc) c on one.aid=c.cid 

 

把查询到结果合并放在一行 JOIN非union

标签:

原文地址:http://www.cnblogs.com/hellowzd/p/5114997.html

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