PHP头条
热点:

thinkPHP三表关联查询,该怎么解决


thinkPHP三表关联查询
三个表,r_hospital表    r_department表        r_doctor表
       id              id hospital_id        id depart_id  hospital_id
三个表所属关系如上,
两个表关联:我会了,
$condition['hospital_id'] = $data;
// 把查询条件传入查询方法
$result = $room->join('r_hospital on r_department.hospital_id=r_hospital.id')->where($condition)->select();  
求三个表关联语句?

$result = $room->join('left join r_hospital on r_department.hospital_id=r_hospital.id  left join doctor on doctor.id = xx.id')->where($condition)->select(); 这语句不对,不知道哪有问题

------解决方案--------------------
可以一直jion下去
------解决方案--------------------
你先把表的主外键关系理清楚,再写sql

www.phpzy.comtrue/phprm/4074.htmlTechArticlethinkPHP三表关联查询,该怎么解决 thinkPHP三表关联查询 三个表,r_hospital表r_department表r_doctor表 ididhospital_ididdepart_idhospital_id 三个表所属关系如上, 两个表关联:我会了, $condition['hospit...

相关文章

相关频道:

PHP之友评论

今天推荐