> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_execute.md).

# mysql\_stmt\_execute

## Syntax

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

## Parameter

* `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.

## Return Value

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" %}
