Query Objects Examples

AVAILABLE API VERSION
API v56.0 and later

Use queries to load record data from Salesforce objects. Only objects supported by UI API are available for querying.

To query an object, request a field with the same name under the RecordQuery type. This example queries accounts with their IDs and names.

The query returns only objects and fields that the user has access to.

You can query multiple objects in one call.

Send your query in a separate call if the query depends on a field or value from an earlier query. Alternatively, work with semi-joins or auto-joins to query parent and child relationships.

This example queries accounts and cases. The second query includes a semi-join using the reference field AccountId, which filters cases whose account parent records match the given Name pattern and Industry field value.

The query returns the first 10 results of each query.

The first query returns accounts with the Name and Industry fields, similar to the following SOQL statement.

The second query is similar to the following SOQL statement.

Multiple query execution where a query requires field or value dependencies on another query within the same execution isn't supported.