# mysql\_real\_query

## Syntax

```c
int mysql_real_query(MYSQL * mysql,
                     const char * q,
                     unsigned long);
```

* `mysql` - a mysql handle, which was previously allocated by [mysql\_init()](/docs/connectors/mariadb-connector-c/api-functions/mysql_init.md) or [mysql\_real\_connect()](/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect.md).
* `query` - a string containing the statement to be performed.
* `long` - length of the string.

## Description

`mysql_real_query()` is a binary-safe function for executing a statement on the database server. Returns zero on success, otherwise non-zero.

{% hint style="info" %}
Contrary to the [mysql\_query()](/docs/connectors/mariadb-connector-c/api-functions/mysql_query.md) function, `mysql_real_query` is binary safe.

To determine if `mysql_real_query` returns a result set, use the [mysql\_num\_fields()](/docs/connectors/mariadb-connector-c/api-functions/mysql_num_fields.md) function.
{% endhint %}

## See also

* [mysql\_query()](/docs/connectors/mariadb-connector-c/api-functions/mysql_query.md)
* [mysql\_num\_fields()](/docs/connectors/mariadb-connector-c/api-functions/mysql_num_fields.md)
* [mysql\_use\_result()](/docs/connectors/mariadb-connector-c/api-functions/mysql_use_result.md)
* [mysql\_store\_result()](/docs/connectors/mariadb-connector-c/api-functions/mysql_store_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-functions/mysql_real_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.
