Relationship Query

The Relationship Query can be used to query multiple sObjects concurrently in the Salesforce.com database.

A relationship is created between those sObjects. Relationship queries follow the SOQL syntax. Parent-to-children and child-to-parent are the two possible relationships between sObjects. In the Salesforce.com database, some sOjects with a relationship are predefined. For example, Account is a parent to Contact. You can use relationship queries to search for sObjects of one type based on criteria that applies to sObjects of another type. For example, “return all accounts created by Bob Jones and the contacts associated with those accounts.” The sObjects are connected either by parent-to-children or child-to-parent relationship, as shown in the following figure: