I have a select statement showing the following results:
On_loan barcode
Y 12345
Y 12345
N 12345
N 12344
Y 12344
Each barcode for a book can have more than one copy. Users can place a book on hold. E.g user '1' has reserved book 12345 and 12344. The above results show: that the two books with barcode 12344- one is available, the other is unavailable. I want to be able to show two regions in PHP, the top showing books that are ready to take out(that were on hold) and the other showing books that are unavailable which have been placed on hold. From my select query i now want my select to check to see for each barcode 12345 and 12344 whether a book has been returned. If it has i will then use the hold_date to see if its the earliest Hold for the specific book.
I understand on_loan informs me whether a book has been returned, however how can i use 'N' from on_loan for each book. I believe distinct will not work.
How can i go about doing this.
My Hold table has the following fields:
user
isbn
hold_date