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...

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:下次弄个可以粘贴的,不然线下没法测试。

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

$data['id'] = array('IN',array(3,6,7,12,34)); $news=$new->where($data)->select(); 相当于 select * from wujiang where id in(3,6,7,12,34)

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

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

array(2) { [0] => array(4) { ["Hotel_Id"] => string(1) "4" ["Hotel_Name"] => string(24) "重庆南方君临酒店" ["Hotel_Stars"] => string(1) "1" ["hotelroomlist"] => array(3) { [0] => array(3) { ["Room_id"] => string(1) "1" ["Room_N...

在 Thinkphp 中有一个 find() 函数,这个函数只返回一条数据。你可以试试, select() 是返回所有的(如果不 limit 的话)

$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