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
kevindotcarkevindotcar 

SOQL Statement Syntax

Hi to all,
Is it true that SOQL statements can now perform joins?
I thought that this syntax would work:

Code:
Select a.ID, a.Account__c, a.SomeField__c, 
(SELECT c.AccountId, c.Name__c from Contact c) 
from Account a Where a.ID = c.AccountId
Thanks in adv for any info/corrections

KC
 


RickyGRickyG
KC -

No, SOQL does not support join syntax.  In fact, the query you list would work, but you do not need (and cannot have) the designated WHERE clause.  SOQL automatically knows about the relationship between Account and Contact, due to the relationship defined between the two objects.  This type of relationship is the only way you can join two objects, so the type of WHERE clause you have in your code is not needed.

Hope this helps.

kevindotcarkevindotcar
Hi RickyG

Yes, that does help.
...With the additional help of the Apex Explorer, and the info here:
  http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm

I was able to clarify my conceptual misunderestandings.

Thanks again for the reply.

KC

RickyGRickyG
KC -

No problem.  It sometimes takes a while to realize that SOQL ain't SQL.