function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kal KumarKal Kumar 

SOQL query for Notes object

I am trying to understand why I cannot query the 'Notes' object directly, but can only use it via the Account relationship.

Below query does not work.
select CreatedBy.Name from Notes.

But this query works
select Name, (select CreatedBy.Name from Notes) from Account
Best Answer chosen by Kal Kumar
Khan AnasKhan Anas (Salesforce Developers) 
Hi Kal,

Greetings to you!

You need to use Note instead of Notes.
SELECT CreatedBy.Name FROM Note

In relationship queries, you need to use Child Relationship Name. Notes is the child relationship name. So, for Parent-Child relationship query you have to use below SOQL:
SELECT Name, (SELECT CreatedBy.Name FROM Notes) FROM Account

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas