www.bzyk.net > thinkphp5 join

thinkphp5 join

表1.typeid=表2.typeid where(array('表1或表2.userid'=>$where))

$m = M(b);$m->join('a on a.id = b.id') ->join('c on c.id = b.id') ->select();

只需要用到Join方法即可 以thinkPhp5为例 Db::table('think_artist')->alias('a')//给主表取别名->join('think_work w','a.id = w.artist_id')//给你要关联的表取别名,并让两个值关联->select();

要,用双下滑下加表名大写方式,例如: $count = D('Document') ->join('__TAG_DOCUMENT__ ON id = document_id') ->where(array('model_id'=>2,'status'=>1,'pid'=>0)) ->count('DISTINCT id');

join是用来联表查询的吧,比如你第一个join()里的内容,表示你联work这个表,连接条件是artist表里的id等于work表里的artist_id,第二个join同理。满意请采纳,不明白请追问。

$wish = $JOKES->join('inner join user on jokes.uid = user.id')->order('time DESC')->limit($limit)->select();

这个非常简单,上面的那种情况M('Admin') 默认使用的表就是sx_admin,而你用自己的sx_admin跟自己的sx_admin连接查询肯定会出问题啊!使用下面的吧 $Re = $Admin -> join('LEFT JOIN sx_user ON sx_user.UID = sx_admin.AUID') -> select()

$Model->table('__COMMENT__ a') ->join('__USER__ b on a.uid=b.id') ->field('a.id,a.content,a.create,a.uid,b.username,b.domain') ->where('a.tid='.$tid) ->order('a.create DESC') ->count();

join是表关联,这里的语句翻译成mysql就是这样: select * from think_Artist inner join think_work on think_Artist.id=think_work.artist_id

可以写两个join $result = $room->join('left join r_hospital on r_department.hospital_id=r_hospital.id ')->join(' doctor on doctor.id = xx.id')->where($condition)->select();

网站地图

All rights reserved Powered by www.bzyk.net

copyright ©right 2010-2021。
www.bzyk.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com