bubble_chart StackLab

Database Migration

19 steps · pending Not started · person_outline Guest
arrow_back Back

View returned books

We can also display borrowing history by looking for records where a return date exists:

code sql
SELECT
    br.borrow_id,

    CONCAT(
        s.student_first_name,
        ' ',
        s.student_last_name
    ) AS student_name,

    b.book_title,
    b.book_author,
    b.book_category,

    br.borrow_date,
    br.borrow_return_date

FROM borrow br

INNER JOIN students s
    ON br.student_id = s.student_id

INNER JOIN books b
    ON br.book_id = b.book_id

WHERE br.borrow_return_date IS NOT NULL

ORDER BY br.borrow_date DESC;
The condition:
code sql
WHERE br.borrow_return_date IS NOT NULL
means:
Show only books that have already been returned.

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