请教各位大神tp5怎么进行多表查询
1个回答
2017-07-28
展开全部
$data=$user->alias('u')
->join('(select a.*,sum(money) summoney from (select * from client_consumption ORDER BY jz_time desc) a group by a.uid ) con','con.uid=u.id')
->join('province p','p.province_id=u.province_id','LEFT')
->join('city c','c.city_id=u.city_id','LEFT')
->join('county co','co.county_id=u.county_id','LEFT')
->join('dev_from d','d.id=u.dev_id','LEFT')
->join('source s','s.id=u.from_id','LEFT')
->join('zx_tools z','z.id=u.tool_id','LEFT')
->join('wangdian_zixun w','w.id=wdzx_id','LEFT')
->join('qiantai_zixun q','q.id=qtzx_id','LEFT')
->join('doctors doc','doc.id=doctor_id','LEFT')
->join('disease dis','dis.id=disease_id','LEFT')
->field('u.id,u.name,u.sex,u.birthday,u.age,u.telephone,p.province_name,c.city_name,co.county_name,d.dev,source_name,z.tool,wd_name wdname,qt_name qtname,doc.doctor,disease_name,jz_time,summoney,addtime')
// ->group('u.id')
->where('name|telephone','like',"%$name%")
->where('summoney',['>',$startmoney],['<',$endmoney],'and')
->order([$sort=>$order])
->limit($offset,$rows)
->select(false);
dump($data);
exit;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询