---
name: "mysql_query"
section: "3"
platform: "linux"
package: "mariadb"
version: "13.0.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mysql_query"
---

# mysql\_query(3)

### Name

mysql\_query - executes a null terminated statement string

### Synopsis

-

  ```
  #include <mysql.h>
  int mysql_query(MYSQL * mysql,
                  const char * query);
  ```

### Description

Performs a statement pointed to by the null terminate string query against the database. Contrary to **[mysql\_real\_query(3)](/mysql_real_query/3.md)**, mysql\_query() is not binary safe.

### Parameter

- •

  `mysql` - a mysql handle, which was previously allocated by **[mysql\_init(3)](/mysql_init/3.md)** and connected by **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**.

- •

  `query` -a null terminated string containing the statement to be performed.

### Notes

- •

  For executing multi statements the statements within the null terminated string statements must be separated by a semicolon.

- •

  If your statement contains binary data you should use **[mysql\_real\_query(3)](/mysql_real_query/3.md)** or escape your data with **[mysql\_hex\_string(3)](/mysql_hex_string/3.md)**.

- •

  To determine if a statement returned a result set use the function **[mysql\_field\_count(3)](/mysql_field_count/3.md)**.

### Return value

Returns zero on success, non zero on failure.

### See also

- •

  **[mysql\_real\_query(3)](/mysql_real_query/3.md)**

- •

  **[mysql\_field\_count(3)](/mysql_field_count/3.md)**

- •

  **[mysql\_hex\_string(3)](/mysql_hex_string/3.md)**

- •

  **[mysql\_use\_result(3)](/mysql_use_result/3.md)**

- •

  **[mysql\_store\_result(3)](/mysql_store_result/3.md)**
