Search code examples
sqljoinsalesforcesoql

SOQL statement joining 2 objects


Having issues retrieving data from 2 different SF objects, a custom object and the accounts object. There is also a field in the Contact object, but first i'm trying to tackle Jobs DB and Account object. Here is the query without the join: 1

Contact__c and Practice_Name__c are both type lookup. I'm not sure what these two values returned are... hopefully keys to be used in where clause? Here you can see relationships: 2 3

Can anyone show me a join that would return the query above with field names rather than foreign keys?

Here is the lookup query with the foreign key for Practice Name above: enter image description here


Solution

  • For accessing to fields of lookup objects you don't need join query, you can just these fields in one query, for instance:

    SELECT Name, Email__c, Contact__r.Name, Practice_Name__r.Name FROM Job_Database__c WHERE Status__c = 'Active'