-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

The MySQL Workshop
By :

Often, you will want to update the data stored within a database table. For example, consider the task list from the Inserting records in Node.js section. When a user adds a task to their database, it is initially marked as incomplete. Rather than having a separate table to store completed tasks, you could, instead, have a field for the task record that keeps track of its status—that is, if the task has been completed or not. Once the task is complete, you can simply modify the record to set the completed
field to yes
. Often, updating an existing record is faster than inserting a new record, so this is a more efficient option.
One important concept to bear in mind before looking at UPDATE
queries is the idea of blocking queries and non-blocking queries in MySQL. A blocking query is a query that needs to be completed in full before the next action can be executed. For example, setting the database using a USE
query would be blocking, as the...