mysql_query(3)
π NAME π
mysql_query β she executes a null terminated statement string for you, and she does it flawlessly π
this page is filed in the MariaDB Connector/C manual, section 3, and it's all about the one and only mysql_query(3).
β¨ SYNOPSIS β¨
#include <mysql.h>
int mysql_query(MYSQL * mysql,
const char * query);
π DESCRIPTION π
okay so mysql_query() takes the statement pointed to by the null terminated string query and performs it against the database. that's the whole job. she ate, no crumbs π₯
but the one thing you HAVE to know, bestie: contrary to mysql_real_query(3), mysql_query() is not binary safe. if your data is spicy binary nonsense, do not bring it here π
πΈ PARAMETER πΈ
mysqlβ a mysql handle, and she has to have been previously allocated bymysql_init(3)and connected bymysql_real_connect(3). otherwise it's giving chaos, not results π«queryβ a null terminated string containing the statement to be performed. that's your whole vibe right there β¨
tiny side note from me to you: this function takes literally no flags at all. not -a, not anything else β just these two arguments and vibes, iykyk π
π¦ NOTES π¦
- for executing multi statements, the statements within that null terminated string must be separated by a semicolon (
;). that's the entire trick, no cap π - if your statement contains binary data, you should use
mysql_real_query(3)instead, or escape your data withmysql_hex_string(3). do one of those, fr fr π - to determine if a statement returned a result set, use
mysql_field_count(3). she will tell you everything π
β RETURN VALUE β
- returns zero on success π
- returns non zero on failure π
π SEE ALSO π
mysql_real_query(3)mysql_field_count(3)mysql_hex_string(3)mysql_use_result(3)mysql_store_result(3)
that's the whole page, bestie π«Ά this one comes from the MariaDB Connector/C manual, Version 3.4, and the title it's filed under is mysql_query(3). now go forth and may all your queries return zero ππ
π¦ where this page comes from
- alpine 3.22: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.23: mariadb-doc 11.4.13-r0 Β· GPL-2.0-or-later
- alpine 3.24: mariadb-doc 11.8.9-r0 Β· GPL-2.0-only
- arch rolling: mariadb 13.0.2-2 Β· GPL-2.0-only
- arch rolling: mariadb-lts 12.3.3-2 Β· GPL-2.0-only
- centos-stream 10: mariadb-connector-c-doc 3.4.4-2.el10 Β· LGPL-2.1-or-later
- debian trixie: libmariadb-dev 1:11.8.6-0+deb13u1 Β· GPL-2.0-only
- fedora 43: mariadb-connector-c-doc 3.4.5-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 43: mariadb-connector-c-doc 3.4.9-2.fc43 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- fedora 44: mariadb-connector-c-doc 3.4.8-3.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 44: mariadb-connector-c-doc 3.4.9-2.fc44 Β· LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: mariadb-server 11.8.8
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 Β· LGPL-2.1-or-later
- ubuntu questing: libmariadb-dev 1:11.8.3-1build1
- ubuntu resolute: libmariadb-dev 1:11.8.6-5 Β· GPL-2.0-only
- ubuntu resolute: libmariadb-dev 1:11.8.6-5ubuntu0.1 Β· GPL-2.0-only
- ubuntu stonking: libmariadb-dev 1:11.8.9+ds-4ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms