Rumah >pembangunan bahagian belakang >tutorial php >thinkphp关联查询问题,join
thinkphp 关联查询
$result = $room->join('r_hospital on r_department.hospital_id=r_hospital.id')->where(array('hospital_id'=>array('exp','is not null')))->select();没人会吗?难到就那么难吗
从字面理解是hostpital_id中非NULL空的都选择
$condition['hospital_id'] = $data;
// 把查询条件传入查询方法
$result = $room->join('r_hospital on r_department.hospital_id=r_hospital.id')->where($condition)->select();
$condition['hospital_id'] = $data;
// 把查询条件传入查询方法
$result = $room->join('r_hospital on r_department.hospital_id=r_hospital.id')->where($condition)->select();
恩,确实是这种方法。三级关联的怎么写,再添加一个医生doctor的id
$condition['hospital_id'] = $data;
// 把查询条件传入查询方法
$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();
$condition['hospital_id'] = $data;
// 把查询条件传入查询方法
$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();
谢了
$condition['hospital_id'] = $data;
// 把查询条件传入查询方法
$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();
这个是三级关联的吗?貌似不行呀。帮我写个三级关联的吧,医生属于科室,科室属于医院这种关系。我弄了很久了,就是不会
请帖出3张表结构