Build a Query by Using the SOQL Builder

The Salesforce Object Query Language (SOQL) Query Builder helps you build a query by using form-like visual interface. You can select the components of your query, such as the table, fields, and filters, instead of typing an actual SOQL query.

To build a query by using the SOQL Builder:

  1. Open the Command Palette and type SFDX: Create Query in SOQL Builder.

    Select the SFDX: Create Query in SOQL Builder command in the Command Palette

  2. Enter a name for the query and press Enter.

  3. In the SOQL Builder, use the UI elements to indicate various parts of your query. In this example, from Accounts, Id, Billing State, and Name details are shown for companies with more than 100 employees. The actual SOQL query appears in the SOQL Query box.

    SOQL Query Builder with Accounts query

  4. Select a table from the From dropdown list.

  5. Select one or more fields to show.

  6. Add one or more filter conditions for the WHERE clause.

    To add a filter, select a field and an operator, and specify a value. To add another filter condition, click ADD and select AND or OR operator. The filters are added in the format WHERE FIELD_NAME OPERATOR VALUE [AND/OR FIELD_NAME OPERATOR VALUE].

    For example, WHERE NumberOfEmployees > 100 OR Name LIKE 'A%'.

  7. To sort the results, select a field as the ORDER BY clause. Specify the order of sorting and how NULL results are shown.

  8. Specify the number of records to limit the results to.

To open the query in a text editor, click Toggle button to open the query in a text editor