This is a regular question in the forum, and here is my take, copied and pasted:
"I have the book that you need."
"I have a first edition of the book, which I suspect is no longer available."
What you need to keep in mind is the idea of restrictive versus non-restrictive clauses, which translates to "necessary" versus "helpful but non-essential."
In the first sentence, the speaker is referring to a very specific book - 'the one that you need" out of all the books he may have. We are therefore restricting, from all the titles of books in the world, our attention down to just one. - Yes, you have books, but is it the one I need? The extra information is 'necesssary.'
Compare the second sentence:
The clause beginning 'which' is non-restrictive and adds some extra interesting information ...but it is not necessary to identify the book: we know it's a first edition. The second clause adds that possibly all first editions are no longer available through commercial channels.
NOTE: no comma is used with 'that', but the main clause is separated with a comma when we use 'which'.
In a sentence such as "The company that invented the microchip we use invited us to a demonstration," the word "that" is relative to "company." There are thousands of companies in the world, but it is important to know the "company that invented the microchip" is specifically the one holding the demonstration. In that sense, the relative clause beginning with 'that' would be considered restrictive, since it is an essential piece of information that identifies the company. You would not write "The company which invented the microchip invited us to a demonstration." in formal writing.
'Which' could be used in a similar sentence constructed this way: "Widgets Incorporated, which invented the microchip we use, has officially declared bankruptcy." In this sentence, the relative clause 'which invented the microchip we use' is separated by commas. The information about the microchip is useful, but not essential to the main idea of the sentence. It could be removed and the sentence would still make sense. If the relative clause can be removed without changing the sentence's meaning, it would be considered non-restrictive.
"The storage building that once stood on the corner has collapsed," would be correct, since the relative clause 'that once stood on the corner' is restrictive and essential - it tells us the specific building in terms of its location - so it would need a restrictive clause beginning with "that." A correct sentence using "which" would read like this: "The Olsen building, which stood on the corner of 12th and Vine Streets, has been torn down." The sentence could still be understood without the non-restrictive clause beginning with 'which'.
In short, whenever the information is essential to identifying the subject, the proper pronoun to use is 'that'. If the information is not essential, or can be set apart with commas, then the pronoun 'which' is more likely to be correct.
If the meaning of the sentence would be lost without the information, then it is most likely restrictive and 'that' would be the proper pronoun to use.
Student or Learner