Say I have two tables doctors and patients Assume patients has two columns: Id and Name Assume doctors has three columns: Id, npi, patientids Each patientids field can have multiple patient's id value. So how can I query patients that belong to the doctor if given the Id of doctors table.
I have tried the following sql, but it does not return anything
select p.Name from patients p
where p.Id in (select patientIds from doctors d where d.Id=@id);