Here is my work for Exercise 9 Updating Data.
For exercise 9, we move to the Update part of CRUD. We change the names for Zed and his pet unicorn.
- Use UPDATE to change my name back to “Zed” by my person.id.
- Write an UPDATE that renames any dead animals to “DECEASED”. If you try to say they are “DEAD” it’ll fail because SQL will think you mean ‘set it to the column named “DEAD”‘, which isn’t what you want.
Since none of the pets are dead, I first update Drogon’s dead status to true. I can then select all of the pets who are dead and rename them to “DECEASED”.
- Try using a subquery with this just like with DELETE.
I used a subquery to get a table of pet names where the pet age was less than 10. I then used UPDATE to set their names to Young One.