VickP07
12-01-2011, 09:35 PM
hey guys so i need a little help writing out this sql query:
I have 4 tables:
patients, prescriptions, UOM, and medications
in my patients table i want to get patients .med_rec, patients .fname, patients .lname
in my prescriptions table i want to get prescriptions.dose
in my UOM table i just want to get UOM.name
in my medications table i just want to get medications.med_name
okay here is where i am confused trying to get the right data to display
in my prescriptions table i have 3 foreign keys:
pat_id, uom_id, and med_id
in each of these fields they contain the patient.patient_id, UOM.unit_id, and medications.medication_id
i want to say something like SELECT patients .med_rec, patients .fname, patients .lname medications.med_name prescriptions.dose UOM.name
where patients.patient_id = 18;
*(later on i will make a variable that will store the patient_id that the user has chosen from a table and pass that where i have 18 right now)
I have 4 tables:
patients, prescriptions, UOM, and medications
in my patients table i want to get patients .med_rec, patients .fname, patients .lname
in my prescriptions table i want to get prescriptions.dose
in my UOM table i just want to get UOM.name
in my medications table i just want to get medications.med_name
okay here is where i am confused trying to get the right data to display
in my prescriptions table i have 3 foreign keys:
pat_id, uom_id, and med_id
in each of these fields they contain the patient.patient_id, UOM.unit_id, and medications.medication_id
i want to say something like SELECT patients .med_rec, patients .fname, patients .lname medications.med_name prescriptions.dose UOM.name
where patients.patient_id = 18;
*(later on i will make a variable that will store the patient_id that the user has chosen from a table and pass that where i have 18 right now)