You need to sign in to do that
Don't have an account?
Marc C.
Mixed-Object SOQL
It is possible to select fields from different objects in one SOQL query (like a JOIN). Example:
SELECT Id, Name, CloseDate, Account.Name, SAPID__c, StageName FROM Opportunity LIMIT 10
But how does one get these results in apex code? I have not found out how to declare the result set:
List<whichType> = [SELECT Id, Name, CloseDate, Account.Name, SAPID__c, StageName FROM Opportunity LIMIT 10];
The list's base type will be the object used in from clause:
Accessing the related SObject is achieved through the same reference as in the query:
You can also just directly pass through the reference:
SOQL - Salesforce Object Query Language
means it can be used only for Querying from one sObject only
IF there are relations we ca use Nested quert for getting the records of Child Objects
For querying from different objects we should use SOSL
and the result set will be
List<sObject>