bubble_chart StackLab

Database Migration

19 steps · pending Not started · person_outline Guest
arrow_back Back

Return a book

Let's say the borrowing record with ID 1 has been returned. We can update it with:

code sql
UPDATE borrow
SET borrow_return_date = CURRENT_TIMESTAMP
WHERE borrow_id = 1
  AND borrow_return_date IS NULL;
Then check the record:
code sql
SELECT * FROM borrow;
Record 1 should now contain a value in:
code text
borrow_return_date
The record is no longer considered an active borrowing transaction.
Why check borrow_return_date IS NULL in the UPDATE?
It prevents the same borrowing record from being "returned" again after it has already been returned.

login Sign in to save your progress permanently. info Progress is saved in your browser session
format_list_numbered Step 16 of 19