Can you fix one York library record without changing any other book?
A York library has a book listed as York Walks with two copies. The title should be York Trails, and there are actually five copies. How can you fix both details without changing any other book?
Use a practice copy of the database. SELECT reads data without changing it. Read the book ID, title and copies from Books. Each book has a unique ID, so WHERE book ID equals two hundred and four previews just that record.
Before the edit, book two hundred and four is York Walks and has two copies. After the edit, the same ID shows York Trails and five copies. The SQL command that edits the row is UPDATE. SET gives the columns their new values.
Book two hundred and four is already in the Books table. You want to change its title and copy count while keeping that same record. Which command should you use? Pick an answer.
Write UPDATE Books to name the table. In SET, give Title the new text in single quotes. Add a comma, then give Copies the number five. Finish with WHERE BookID equals two hundred and four. That unique ID limits the edit to one row.
Book three hundred and seventeen needs a new title, Leeds Walks, and a copy count of eight. The UPDATE and WHERE lines are ready. Which SET line gives both columns their new values? Pick an answer.
After you run the UPDATE on the practice copy, run the same SELECT again. Compare its result with the preview. Book two hundred and four still has the same ID, while the title and copy count now show the values you wanted.
With WHERE book ID equals two hundred and four, both assignments apply only to that record. If you leave WHERE out of the written command, both assignments apply to every row. SQL does not stop after the first row.
To add a test row on your practice copy, INSERT INTO names Books and lists the columns. VALUES supplies the new ID, title and copy count in that order. To remove that row afterwards, use DELETE FROM Books with a WHERE condition that matches book three hundred and eighteen.