Newby287
05-25-2009, 08:49 PM
OK, so I'm trying to get the admission id, name and ward name for patients who have been admitted but not operated on. The four tables used are PERSON, ADMISSION, OPERATION and WARD. Admission id and ward code are in admission, and Admission id is in admission and operation
What I have is:
SELECT ADMISSION.Admission_id, PERSON.First_name, PERSON.Surname, WARD.Ward_name
FROM ADMISSION, PERSON, WARD
Where ADMISSION.Patient_id = PERSON.Person_id
AND ADMISSION.Ward_code IS NOT NULL
AND ADMISSION_id NOT IN (SELECT ADMISSION_id FROM OPERATION);
This brings up six rows - the first two lines are correct, but then it gives additional lines for each of the two people for the other two ward names. I tried a nested select query to ispolate the Ward Codes for the two specific people but it didn't work.
Any ideas?
What I have is:
SELECT ADMISSION.Admission_id, PERSON.First_name, PERSON.Surname, WARD.Ward_name
FROM ADMISSION, PERSON, WARD
Where ADMISSION.Patient_id = PERSON.Person_id
AND ADMISSION.Ward_code IS NOT NULL
AND ADMISSION_id NOT IN (SELECT ADMISSION_id FROM OPERATION);
This brings up six rows - the first two lines are correct, but then it gives additional lines for each of the two people for the other two ward names. I tried a nested select query to ispolate the Ward Codes for the two specific people but it didn't work.
Any ideas?