For this kind of clause, you need a comma, and then you strictly should use “whom”
Because “the doctor” is the subject of the sentence, but the object of the clause “my grandmother liked”, you must use a comma to offset the sub-clause, like this:
- The doctor, whom my grandmother liked, lives in New York
Strictly, you do need to use “whom” in these clauses, because in “my grandmother liked the doctor”, “the doctor” is the object of the verb in that clause. However, this is a losing battle in modern English, and in speech most native speakers will say “who” here. In careful writing, “whom” is still used.
Without the comma, it’s always “who”
There’s another kind of relative clause, and that’s the “defining relative clause”. This kind of clause gives information that defines a noun (subject or object) in its main sentence. For instance, here:
- The doctor who charmed my grandmother lives in New York.
These clauses don’t use a comma, and always use “who” for people, not “whom”. The reason should be obvious when you split the sentence into two:
- The doctor charmed my grandmother. The doctor lives in New York.
… “the doctor” is the subject of both sentences, so “who” is correct.
This also applies when the object is shared by both verbs, as in this example:
- Deborah married the doctor who my grandmother liked.
- Deborah married the doctor. My grandmother liked the doctor.
Incidentally, “who” is used for both singular and plural subjects, but any verb in the clause after “who” still has to change to match the subject:
- The doctor who treats my grandmother live in New York.
- The doctors who treat my grandmother live in New York.
For inanimate nouns, “that” is used:
- The hospital that treat my grandmother is in New York
- We visited the hospital that treats my grandmother.
deletion of “who”/“that” in defining clauses
In many cases, you can delete the word “who” (or “that”) in these sentences:
- good: Deborah married the doctor
who my grandmother liked.
- good: Janet wore the dress
that she bought in Milan
- good: The dress
that Janet bought in Milan was very pretty.
But, not always:
- wrong! We visited the hospital
{that} treats my grandmother.