Both of these work to a certain degree, but neither is returning the desired result.
CREATE TEMPORARY TABLE `tmplist`
SELECT medicalrecords.resident_id, medicalrecords.medicalrecorddate
FROM medicalrecords
GROUP BY medicalrecords.resident_ID;
SELECT residents.resident_id, residents.lastname FROM `residents`
LEFT JOIN tmplist AS t1 ON (residents.resident_id=t1.Resident_ID)
ORDER BY residents.lastname
DROP TABLE tmplist
Returns ONLY resident_id, lastname from `residents`.
CREATE TEMPORARY TABLE `tmplist`
SELECT medicalrecords.resident_id, medicalrecords.medicalrecorddate
FROM medicalrecords
GROUP BY medicalrecords.resident_ID;
SELECT * FROM `residents`
LEFT JOIN tmplist AS t1 ON (residents.resident_id=t1.Resident_ID)
ORDER BY residents.lastname
DROP TABLE tmplist
Returns all from `residents` (120 columns) AND resident_id, medicalrecorddate from `tmplist`.
What I want returned are 4 colums: resident_id, lastname from `residents` and resident_id, medicalrecorddate from `tmplist`.
Any help is greatly appreciated.
CREATE TEMPORARY TABLE `tmplist`
SELECT medicalrecords.resident_id, medicalrecords.medicalrecorddate
FROM medicalrecords
GROUP BY medicalrecords.resident_ID;
SELECT residents.resident_id, residents.lastname FROM `residents`
LEFT JOIN tmplist AS t1 ON (residents.resident_id=t1.Resident_ID)
ORDER BY residents.lastname
DROP TABLE tmplist
Returns ONLY resident_id, lastname from `residents`.
CREATE TEMPORARY TABLE `tmplist`
SELECT medicalrecords.resident_id, medicalrecords.medicalrecorddate
FROM medicalrecords
GROUP BY medicalrecords.resident_ID;
SELECT * FROM `residents`
LEFT JOIN tmplist AS t1 ON (residents.resident_id=t1.Resident_ID)
ORDER BY residents.lastname
DROP TABLE tmplist
Returns all from `residents` (120 columns) AND resident_id, medicalrecorddate from `tmplist`.
What I want returned are 4 colums: resident_id, lastname from `residents` and resident_id, medicalrecorddate from `tmplist`.
Any help is greatly appreciated.