# Query

### Introduction

A query allows you to select a source target based on specific criteria. You can associate a segment code with the query results and insert additional data into it. By customizing the search parameters, you can obtain query results tailored to your criteria for work items. A query consists of various conditions that define your search, bringing results in line with the set parameters.

#### Query Creation Process

**Example Query**: Get Salesforce Accounts and print using Debug.

1. **Configure the Flow**: Drag and drop a **Flow** action. Click **Configure** and provide a description for the flow (for example, Get SF Accounts Information).

   <figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2F9455mea1ztGPEyCoXvPf%2Funknown.jpeg?alt=media&#x26;token=f7c0613c-ee2b-4faf-8f26-1edff51a4125" alt=""><figcaption></figcaption></figure>
2. Click **Save**.
3. **Configure the Query**: Drag and drop a **Query** action. Click **Configure**, select the **Source** as Salesforce, and **Object** as Account.

   <figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FZqE2hotl4WQxYwx4kHFV%2Funknown.jpeg?alt=media&#x26;token=f969ef78-e5bf-45ca-9d3a-f832e6819272" alt=""><figcaption></figcaption></figure>
4. In the **Configure** Query section, either click **All fields** or specific Salesforce fields, as needed. For this process, click **All Fields**.
5. **Preview the Results**: Click **Preview** from the **Configure** Query section. The Salesforce records will be displayed as Rows in the Result section.&#x20;
6. **Save** the query action. To understand about Where and Related Objects, refer to the Additional Information section below.
7. **Debug the Query**: Drag and drop a **Debug** action. Click **Configure** and define the variable. ![](https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FtEQ91jyNq4W1AvGo7toy%2Funknown.jpeg?alt=media\&token=f0b3f031-620b-4c1a-95ef-467d2b6ac22f)
8. Click the fx icon to access the schema, then drag and drop the name schema onto the debug panel. Select the correct Name field to display the Salesforce account names.

> **PRO TIP**
>
> When using the Debug action, ensure you select the correct field schema to avoid confusion and ensure accurate data output.

**Run the Integration:**

9. Click the **Close** icon and **Save**.

   <figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2F1FFUPBAb89JCKZ4y05f0%2Funknown.jpeg?alt=media&#x26;token=8f1adf11-d718-4c6f-8eb2-fda7ef3b679b" alt=""><figcaption></figcaption></figure>
10. Click **Run** ![](https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2F9cr7D1SKy7JNX1c0ZJGO%2Funknown.png?alt=media\&token=4ec1d46a-772f-468d-8965-854a6e17d33c)to execute the integration.
11. The console will display the executed query and print the Salesforce Account Names.

![](https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FFuC7YISGEPAfPVWIEm3H%2Funknown.jpeg?alt=media\&token=9f4afb1f-c3fd-4dc4-b8c0-035b93477f51)

### Additional Information

**Where** and **Related Table/Object** fields are used to refine and manage how data is retrieved from a data source.

**Where** allows you to specify the conditions or filters for your query. By using **Where**, you can limit the results to only those that meet certain criteria. For example, if you want to pull records where the status is active, use Where field to define that condition.

**Related Table/Object** refers to the ability to include data from related entities or objects in your query. For example, if you're querying an Account object, and you need to pull data from related objects, like Contacts associated with that account, use **Related Table/Object** to get comprehensive datasets that reflect relationships between different data elements.

| <p><strong>1. Can I use multiple conditions in a single query?</strong></p><p>Yes, you can create queries with various conditions to customize your search parameters and obtain results based on specific criteria.</p><p></p><p><strong>2. How do I preview the results of a query before executing it?</strong></p><p>Click the 'Preview' option in the 'Configure Query' section to display all relevant objects in the results section before executing the query.</p><p></p><p><strong>3. What are the benefits of using queries in workflows?</strong></p><p>Queries allow users to select targets based on criteria, customize search parameters, and associate segment codes with query results, enabling efficient data management and workflow automation.</p><p></p><p><strong>4. What are the different data sources I can query from?</strong></p><p>You can query from various data sources, including Salesforce and other JDBC-compliant databases like MySQL, Oracle, and DB2.</p><p></p><p><strong>5. Can I combine data from multiple objects or tables in a single query?</strong></p><p>Yes, you can combine data from multiple objects/ tables in a single query in DBSync Cloud Workflow, but it depends on the source system and the query type you’re using.</p> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

## Related Content

[Log Management](https://docs.mydbsync.com/cloud-workflow/dbsync-platform/administration/logs) - This section explains how to manage and view logs in DBSync, helping you troubleshoot and monitor integration processes.

[Transformation Examples](https://docs.mydbsync.com/cloud-workflow/flow-builder/transform-and-write) - This page offers examples of how to use query transformations in your integration projects within DBSync.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mydbsync.com/cloud-workflow/2026_create-your-workflow/action/query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
