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);