2022 Developer Survey is open! Take survey.
2 of 3
added 228 characters in body
Mohith Shrivastava
  • 85.9k
  • 18
  • 138
  • 192

Whenever we have to query multiple objects like in your case you need to query Case and Case comments prefer SOSL to query efficiently.

There is already a great reference to understand the difference between soql and sosl in below link when to use SOSL and SOQL

So a SOSL on the case and case comments will be needed .

Let me run through a how to use developer console for SOSL.Great news is we can use developer console of for writing the SOSL query

Here is the sample query.Please modify as you needed

FIND {hello} IN ALL FIELDS RETURNING case(Id,CaseNumber),casecomment(ParentId,CommentBody,Parent.CaseNumber)*

The screenshot of how the result looks like

enter image description here

UPDATE:

This is how the query will include where clause

FIND {hello*} IN ALL FIELDS RETURNING case(Id,CaseNumber where createddate<TODAY),casecomment(ParentId,CommentBody,Parent.CaseNumber where ParentID!=null) 
Mohith Shrivastava
  • 85.9k
  • 18
  • 138
  • 192