ref – https://www.grammar-monster.com/glossary/relative_pronouns.htm
Relative Pronoun – a pronoun that heads an adjective clause.
-
that
[The dog (that) stole the pie] is back.
-
which
- My new dog, (which) I bought last year, loves green beans.
- I rode my bike, (which) now had two bent spokes, back home.
-
who
- [The person (who) bought his car] found gold under the seat.
- [The girl (who) stole your phone] is outside.
- Mrs Miggins, (who) owns a pie shop, is outside.
-
whom
Our lawyer, (whom) we employed for over a year, was related to the complainant.
-
whose
The young girl (whose) cat scratched our sofa has offered to replace the cushions.
Do you put a comma before the relative pronoun (except ‘that’)?
The answer is sometimes yes and sometimes no. (Actually, it doesn’t apply to “that,” but we’ll cover that point later.) Look at these two examples using “who”:
The man who won last week’s lottery gave all his money to a donkey sanctuary.
My neighbour, who won last week’s lottery, gave all his money to a donkey sanctuary.
These two sentences are nearly identical, but one has commas and one doesn’t. They are both correct.
It all depends whether the adjective clause (the highlighted text) specifies its noun.
If it does (like in the first example, where it specifies “the man”), then don’t use commas. If it doesn’t (like in the second example, where it’s just additional information about “my neighbour”), then use commas.