
Hi i have the following 3 tables, example data inside them
patients : 1,DUMMY PT, 78936, 1987-07-18
Custom_fields : 1 , 1 , ‘blood pressure’ , input , ‘medical records’
patient_info : 1, 1 , 80/90 blah blah , 1
what i want is when i very patient page, is to get ALL rows of ‘patient_info’ where pt_id=patients.patient_id and then get custom_fields.title=cf_id where doctor_id=$id
and show all.
from above given example of data it should looks like this:
Patient: DuMMY pt profile page :-
blood pressure : 80/90 blah blah
any hints how i should join this tables together ?
Note: i tried :
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
where 10 and 8 are already givens ($vars in php) but im getting error near ‘join patients on’
Try this: