Queries That Return No Resultset

Now that you've mastered SELECT queries, you should find that queries to update, delete, and insert data and even queries to create tables are straightforward. However, they have the characteristic that they return no resultset. As you'll see, you need to look carefully at the result returned so that you know whether your query failed with an error, or whether it succeeded, and if so what difference it made to the database.

In the next simple example, we'll write a query that creates a temporary table. Let's assume that we may want to do an UPDATE and get some feedback that the query has worked. This feedback comes via the statement handle:

 my $sql = "UPDATE subscribers SET name='New name', email='New\@email' ...

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.