walid walid - 6 months ago 12
SQL Question

How to get data about library members who returned their books after a specific period

I would like to get all the members who late the borrowed books returned. I have a borrowing table,examples of books table and the members table

Which statement should be used to retrieve the data of which member return after 30 days the books?

I hope this a clear explanation. Thanks in advance for your help!

This is the borrowing table:

enter image description here

This is the members table:

enter image description here

GGG GGG
Answer

From what I can make of the images, the following query should work with some modifications:

SELECT Us.*, Bo.* FROM Borrowings Bo
    INNER JOIN Users Us
        ON Bo.LID_LIDNUMMER = Us.LIDNUMMER
            WHERE Bo.DATUM_BORROWED - Bo.DATUM_RETURNED > 30