Running Queries That Return a Resultset

When a program has a live connection to a MySQL database, two functions are available for running a query: mysql_query() and mysql_real_query().

You can use these functions to run any kind of query: those that return a resultset (such as the SQL statements SELECT, DESCRIBE, and SHOW) and those that don't (such as INSERT, UPDATE, and DELETE). Initially we'll concentrate on queries that return a resultset, so you'll see how to run the query and process the data that is returned.

mysql_query() expects a string terminated by a null, whereas mysql_real_query() takes a counted string. For our simple examples, you can use mysql_query(); however, if you need to create a query that contains binary data (which may ...

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.