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

thinkphp子查询

时间:2015-02-03 22:48:59      阅读:450      评论:0      收藏:0      [点我收藏+]

标签:

实现一条语句:

SELECT provinceid,provincename from tsh_province where provinceid in(

SELECT DISTINCT gs_provinceid from tsh_greenschool)

 

 

thinkphp:

 $subquery=M(‘greenschool‘)->field(‘gs_provinceid‘)->group(‘gs_provinceid‘)->select(false);

$result=M(‘province‘)->fetchSql(true)->field(‘provinceid,provincename‘)->where(‘provinceid in ‘.$subquery)->select();

thinkphp子查询

标签:

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

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