> For the complete documentation index, see [llms.txt](https://docs.diaflow.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.diaflow.io/workflow-builder/nodes/database/mysql.md).

# MySQL

## What this node helps you do

Use the **MySQL** node when your workflow needs data from an existing MySQL database.

This node helps you:

* find records from a MySQL table
* add new rows after a form, approval, or workflow step
* update existing records when business data changes

<figure><img src="/files/lj8DtqbVJiqVpP7MaOWc" alt=""><figcaption></figcaption></figure>

### Common business examples

Teams often use this node to:

* look up a customer before sending a reply
* save a new lead into a CRM table
* update an order, ticket, or approval status

## Available actions

The **Action** field gives you 3 options:

* **Query data from table** — find or retrieve data from a selected table
* **Add a row** — create a new record in the table
* **Update record** — change an existing record in the table

## Basic setup

### 1. Select resource

Choose the MySQL connection your workspace should use.

If you do not see the right connection, open **Manage** and add it in **Workspace → Integrations**.

### 2. Select table

Choose the table that contains the business data you want to use.

Examples include `customers`, `orders`, `tickets`, or `leads`.

### 3. Choose the action

Pick what the workflow should do with that table:

* read data
* add data
* update data

<figure><img src="/files/W6cQRjOJJZsYC6td0MEj" alt=""><figcaption></figcaption></figure>

## Query data from table

Choose **Query data from table** when you need to search or retrieve information.

This action includes **SQL Generate Method** with 2 options:

* **Use AI** — describe what you want in plain language
* **Manually enter SQL** — write the SQL query yourself

### Use AI

Choose **Use AI** if you want a faster setup and do not want to write SQL.

In **Input**, describe the result you want.

Examples:

* `Find the latest order for this email`
* `Get open tickets for this customer`
* `Show all leads created this month`

Diaflow uses that instruction to generate the SQL query for you.

### Manually enter SQL

Choose **Manually enter SQL** if your team already has a specific query.

Enter the SQL in the code editor.

Use this option when you need exact control over filters, joins, or sorting.

## Add a row

Choose **Add a row** when your workflow needs to save a new record.

This is useful after:

* a form submission
* a lead capture flow
* a document or AI extraction step

Make sure the values you send match the columns in the selected table.

## Update record

Choose **Update record** when your workflow needs to change data that already exists.

This is useful when you need to:

* change a status
* assign an owner
* save a result back into the database

Make sure your workflow identifies the correct record before updating it.

## Field reference

* **Select resource** — chooses the MySQL connection
* **Table** — chooses the table the node will use
* **Action** — decides whether the node reads, adds, or updates data
* **SQL Generate Method** — appears for query actions and lets you use AI or manual SQL
* **Input** — plain-language instruction for AI-generated queries
* **Code editor** — SQL entry area for manual queries

## Tips for first-time users

* Start with **Query data from table** to confirm the connection works.
* Use a simple table first, such as customers or orders.
* If you are not sure what to write, use **Use AI** before trying manual SQL.
* Check the **Result** tab after each test run.

{% hint style="info" %}
If you are unsure which table or fields to use, ask your database owner or technical team first.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.diaflow.io/workflow-builder/nodes/database/mysql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
