DEV Community

Discussion on: Need help with sql (*_*) !

Collapse
 
richardpaulhall profile image
richardpaulhall

Did you start by writing a query that gave the results you wanted?
Like:

SELECT firstname
FROM users
WHERE Appointments.patient_id = patients.user_id
AND patients.user_id = user.id

(I do not have all the criteria to write the query you need.)
As your code has no literal SQL, the problem is either your query or your implementation of it in whatever you are writing.