Excerpt from Professional Linux Programming
Like PostgreSQL, MySQL can be accessed from many different languages, including C, C++, Java and Perl. Using the comprehensive C interface of MySQL, Neil Matthew and Richard Stones show us how to execute SQL statements in MySQL databases in the following sections from Chapter 5 on MySQL from Professional Linux Programming. They will look at both statements that return data, such as INSERT, and those that don't, such as UPDATE and DELETE. They will then write a simple program that retrieves data from the database.
Executing SQL statements
Now we have a connection, and know how to handle errors, it's time to look at doing some real work with our database. The principal keyword for executing SQL statements of all types is mysql_query:
|
As you can see, there is very little to it. It takes a pointer to a connection structure and a text string containing the SQL to be executed; unlike the command line tool, no terminating semicolon should be used. On success, zero is returned. In the special case that you need to include binary data, you can use a related function, mysql_real_query . For the purposes of this chapter though, we only need to look at mysql_query.
View Executing SQL statements in MySQL databases using C Discussion
Page: 1 2 3 4 5 Next Page: SQL statements that return no data