---
schema_version: "1"
id: 2bf3fe4f070279229f3b580e5f5630adbab4cc65efcbaab3742e4478bebe0bcb
title: Build a Query by Using the SOQL Builder
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/webconsole/guides/query-records/query-builder.md
canonical_url: https://developer.salesforce.com/docs/platform/webconsole/guide/query-builder.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 89101e73a67e0f213104c5fc978e1ca35ca3a204c95251c474ed2872f3f449e1
products:
  - Web Console
  - salesforcedx
---
# Build a Query by Using the SOQL Builder

The Salesforce Object Query Language (SOQL) Query Builder is a part of the Salesforce Extension Pack. This builder helps you build a query by using a 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. You can instantly view query results, and then save the results to a `.csv` or a `.json` file.

Build simple query statements that include:

- `SELECT` clause to pick fields from the selected object, or `COUNT()` to perform an aggregation of the results
- `FROM` clause for only one object type
- `WHERE` clause to filter your data
- `ORDER BY` clause with support for `ASC`, `DESC`, `NULLS FIRST`, and `NULLS LAST`
- `LIMIT` clause

To dig deeper regarding SOQL syntax or to build more complex queries, see the [SOQL and Salesforce Object Search Language (SOSL) Reference guide](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_sosl_intro.htm).

**note:** To build more complex queries, you can use the text editor.

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](https://developer.salesforce.com/docs/platform/media/shared/command_soql_builder.png '{"class": "image-lg image-framed"}')

2. Enter a name for the query.
3. Select the default directory or specify a directory where the query is stored, and press Enter.
4. In the SOQL Builder, use the UI elements to indicate various parts of your query. In this example, from `Account`, `Id`, `BillingCountry`, and `Name` details show for companies with more than 100 employees. The actual SOQL query appears in the **SOQL Query** box.

   ![SOQL Query Builder with Accounts query](https://developer.salesforce.com/docs/platform/media/shared/query_builder.png '{"class": "image-lg image-framed"}')

5. Select an object from the **From** dropdown list.
6. Select one or more fields to show.
7. 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%'`.

8. To sort the results, select a field as the `ORDER BY` clause. Specify the order of sorting and how NULL results are shown.
9. 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](https://developer.salesforce.com/docs/platform/media/shared/query_toggle.png '{"class": "image-icon-lg"}').

## Open an Existing File

- The `.soql` files containing the queries are saved in the `<project-folder>/scripts/soql` directory.
- The `.csv` and `.json` files with your query results are stored under the `<project-folder>/.sfdx/data` directory.

![Explorer view with CSV and SOQL files](https://developer.salesforce.com/docs/platform/media/shared/existing_csv_soql_files2.png '{"class": "image-sm image-framed"}')

To open an existing file in the text editor, click the file in the explorer or drag the file onto the editor. To open the query in the SOQL Builder, click ![Toggle button to open the query in a text editor](https://developer.salesforce.com/docs/platform/media/webconsole/query_toggle.png '{"class": "image-icon-lg"}').

