Lesson 25
Changing Data
In this lesson, you learn how to change the data in your database using the UPDATE command.
There are multiple ways to process MySQL data commands. You have been using variations on similar methods. In this lesson you learn a new way with prepared statements where you set up the statements first and then you supply the field data separately. Prepared statements are inherently safer because they discourage SQL injections.
The examples from this lesson use the same tables used in the examples in Lesson 24.
You can download the code for this example from the book's web page at www.wrox.com. You can find them in the Lesson25 folder in the download in a file labeled lesson25a.sql.
The first table is the authors table as shown in Figure 25-1.
The second table is the types table as shown in Figure 25-2.
The third table is the books table as shown in Figure 25-3.
Using the UPDATE Command
The UPDATE command is used to change the data in your tables. To change row 1 in the authors table from Sally Meyers to Sarah Meyers, use ...