# mysql\_stmt\_execute

## Syntax

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

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

## Description

Executes a prepared statement which was previously prepared by [mysql\_stmt\_prepare()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_prepare). 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](https://app.gitbook.com/s/SsmexDFPv2xG2OTyO5yV/reference/sql-statements/data-manipulation/changing-deleting-data/update), [DELETE](https://app.gitbook.com/s/SsmexDFPv2xG2OTyO5yV/reference/sql-statements/data-manipulation/changing-deleting-data/delete), or [INSERT](https://app.gitbook.com/s/SsmexDFPv2xG2OTyO5yV/reference/sql-statements/data-manipulation/inserting-loading-data/insert), 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()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mariadb_stmt_execute_direct)
* [mysql\_stmt\_prepare()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_prepare)
* [mysql\_stmt\_bind\_param()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_bind_param)
* [mysql\_stmt\_next\_result()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_next_result)

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