小新新2015

导航

 

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);
posted on 2015-02-03 22:16  小新新2015  阅读(762)  评论(0编辑  收藏  举报