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

thinkphp多表联合查询

也是用join的。你可以看下手册。

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

$Model = M('Artist'); $Model->join('think_work ON think_artist.id = think_work.artist_id') ->join('think_card ON think_artist.card_id = think_card.id')->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...

select count(m.school_id) as sid,s.school_name,m.mat_name from school as s left join mat as m on s.id = m.school_id 闲的无聊,回答问题,手机手打,打错-_-||自己排错

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

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

你的这个要求靠一条SQL做出来估计不行。你说的这个条数的和,是指表一中的所有数据条数加上表二所有数据条数吗?如果是这样就要分两次来查询。 具体的实现步骤可以这样: 1、把excel表格里面的项目数据读取到一个数组里面, 2、循环数组里面的每...

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

对前台传来的商品id数组在表中进行查询 //$goods = array(11,10,7); $where['goods_id']=array("in",$goods); $where['user_id'] = $_SESSION['uid']; $res = D("cart")->where($where)->select(); 复制代码 得到sql语句如下 "SELECT * FROM `ca...

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