The next part of CRUD is UPDATE! In phpMyAdmin, select the
dog table as usual, and make sure that the Browse tab is highlighted. Then click the "Edit" button to the left of a row, and change the dog's name.
Here is the SQL that got generated when I did the update:
UPDATE `dog` SET `name` = 'Mustard' WHERE `dog`.`dog_id` = 1;
I'll rewrite it with line breaks like this:
UPDATE `dog`SET `name` = 'Mustard'WHERE `dog`.`dog_id` = 1;
The SQL keywords to perform the update are
Updating multiple records
You can write SQL to update multiple rows of a table. We could change the SQL above to this:
UPDATE `dog`SET `name` = 'Catsup'WHERE `dog`.`dog_id` > 0;
This SQL statement will change all the dogs' names to Catsup!
WHERE clause, I am asking the database to perform this operation on each dog's whose
dog_id is greater than zero. That would be all the dogs!
So watch out - SQL is powerful and fast, and there is no undo key.
As you can see,
UPDATE is pretty straightforward. Erasing records is also not very complicated, and that's what comes next!