嗨,我有以下 3 个表,其中包含示例数据
患者:1,DUMMY PT, 78936, 1987-07-18
Custom_fields : 1 , 1 , '血压' , input , '病历'
患者信息:1、1、80/90 等等等等,1
我想要的是当我非常耐心的页面时,获取 'patient_info' 的所有行,其中 pt_id=patients.patient_id 然后获取 custom_fields.title=cf_id where doctor_id=$id 并显示全部。
从上面给出的数据示例来看,它应该如下所示:
患者: DuMMY pt 个人资料页面:-
血压:80/90 等等
任何提示我应该如何将这些表连接在一起?
注意:我试过:
SELECT patient_info.info,custom_fields.title FROM patient_info where patient_info.pt_id='8' and custom_fields.id=patient_info.cf_id and custom_fields.doctor_id = '10'
join patients on patient_info.pt_id=patients.patients_id
join custom_fields on patient_info.cf_id=custom_fields.id
其中 10 和 8 已经给出(php 中的 $vars),但在“加入患者”附近出现错误