# mysql\_stmt\_execute

## Syntax

```c
int mysql_stmt_execute(MYSQL_STMT * stmt);
```

* `stmt` - A statement handle, which was previously allocated by [mysql\_stmt\_init()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_init.md).

## Description

Executes a prepared statement which was previously prepared by [mysql\_stmt\_prepare()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_prepare.md). When executed any parameter markers which exist will automatically be replaced with the appropriate data.

Returns zero on success, non-zero on failure.

{% hint style="info" %}
If the statement is [UPDATE](/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/update.md), [DELETE](/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/delete.md), or [INSERT](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert.md), the total number of affected rows can be determined by using the `mysql_stmt_affected_rows()` function. Likewise, if the query yields a result set, the `mysql_stmt_fetch()` function is used.
{% endhint %}

## See Also

* [mariadb\_stmt\_execute\_direct()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mariadb_stmt_execute_direct.md)
* [mysql\_stmt\_prepare()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_prepare.md)
* [mysql\_stmt\_bind\_param()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_bind_param.md)
* [mysql\_stmt\_next\_result()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_next_result.md)

{% @marketo/form formId="4316" %}


---

# 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://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_execute.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.
