Reputation: 89
Hi I want to select a row with max ID(primary key) value having patient_id=xyz
following is my sql script
check="Select * from notes where id=max(ID) in (SELECT * FROM notes WHERE patient_id="+patientSoapBean.getPatientID()+")";
I am getting invalid use of group function error. can you point out the error in this.
Upvotes: 0
Views: 99
Reputation: 71422
You likely are trying to do this:
SELECT * FROM notes
WHERE patient_id = ?
ORDER BY id DESC
LIMIT 1
Upvotes: 2