rchg.net
当前位置:首页 >> thinkphp多表联合查询 >>

thinkphp多表联合查询

以一个 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...

以一个 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...

用left join 但是,我没有看懂人的意思,你这里是有两个,还是三个表? ON B.room_id = b.room_id 这里又是什么意思?

$aa=$D('ab')->join(B ON A.day=B.day)->where($dada)->select();

可以直接写sql,不是一定要用thinkphp的组合语法埃 M()->Query("select * from tableA a left join tableB b on a.id=b.id left join tableC c on b.id=c.id where c.id=1");// 类似这样

M('user')->field('u.*')->join('u left join new n on n.userid = u.userid')->select();echo M('user')->getLastSql();// 查看上一条sql语句

M("User u")->join("sex s,deparment d,job j")->where("u.sex=s.id,u.department=d.id,u.job=j.id")->select(); ps:下次弄个可以粘贴的,不然线下没法测试。

M('item')->join('repayment ON item.关联字段 =repayment.关联字段')->where('表名.user_uid = '.$value['id'])->getfield('字段')

$xl = array('czxl','gzxl','dxxl');foreach($xl as $v){ $return = $db->query("select * from $v where username='$name'"); if($return) break;}var_dump($return);

$ObjTbvcbgroupmap = M('B');//M一个中间桥梁方法 $arrData = $ObjTbvcbgroupmap ->field('*') ->join('A ON A.ngroupid = B.ngroupid')/*关联表*/ ->join('C ON C.nvcbid = B.nvcbid') /*关联表*/ ->select(); echo ''; print_r($arrData);//这...

网站首页 | 网站地图
All rights reserved Powered by www.rchg.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com