码迷,mamicode.com
首页 > Web开发 > 详细

thinkphp groupby demo

时间:2015-02-03 22:54:56      阅读:556      评论:0      收藏:0      [点我收藏+]

标签:

sql:

select cityid,cityname from tsh_city where cityid in(
select gs_cityid from tsh_greenschool group by gs_cityid 
);
 
 
thinkphp:      
 
$subquery=M(‘greenschool‘)->field(‘gs_cityid‘)->group(‘gs_cityid‘)->select(false);
     $citylist=M(‘city‘)->field(‘cityid,cityname‘)->where(‘cityid in ‘.$subquery)->select();
     $temp=‘‘;
     foreach ($citylist as $value) {
     $temp=$temp.$value[‘cityname‘];
     }
     dump($temp);

thinkphp groupby demo

标签:

原文地址:http://www.cnblogs.com/panqingqiang/p/4271187.html

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