www.bzyk.net > thinkphp5 join

thinkphp5 join

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

$wish = $JOKES->join('inner join user on jokes.uid = user.id')->order('time DESC')->limit($limit)->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();

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

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

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

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

以一个 user 表和 jifen 表联查为例,, 第一种方式: $data = M('user as a')->join('jifen as b on b.id = a.id')->where('a.id = 1')->select(); 第二种: $data = M()->table('user as a')->join('jifen as b on b.id = a.id')->where(' a.id...

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

可以写两个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