which are almost always one-to-many. Specify these relationships using a subquery (enclosed in parentheses), where the initial member of the FROM clause in the subquery is related to the initial member of the outer query FROM clause. Note that for standard object subqueries, you should specify the plural name of the object as that is the name of the relationship for each object.
For example
Parent field name1, field name2, field name3,(SELECT field name1, field name2, field name3, from Child Relationship Name ) from Parent object
SELECT Name, ( SELECT LastName FROM Contacts ) FROM Account
The query returns the name for all the accounts, and for each account, the last name of each contact.
Recent Comments