I need to search the database for the last 4 most recent records, with the exr_exa_id
column matching the reported id's, and exr_exa_id
can not be duplicated.
I tried to group in a few ways, but I was not successful, because it either does not display the most recent records, or it displays equal records in the exr_exa_id
column (see image).
Can you help me?
SELECT *
FROM exa_exameresultado
WHERE
exr_exa_id IN (18,19,20,71) AND
exr_pac_id = 2128
ORDER BY
exr_data DESC,
exr_exa_id ASC
LIMIT 4