Hi there,
I have executed a code
SELECT CASE b.ON_LOAN
when 'Y' then
'In Lib'
when 'N' then
(SELECT c.duedate from book_copy a, book b, loan c
where b.isbn = 123456
and a.isbn = b.isbn
and a.book_no = c.book_no)
END AS Availability, a.isbn, a.class_number
FROM book_copy b, book a
where a.isbn = b.isbn and a.isbn = 123456
it returns an error saying subquery returns more than one row . I am trying to get the availability for a book. A book can have more than one copy, that is identified by its book_no. If a copy is available it should retrun just 'In lib' otherwise, the duedate from loan table. E.g if a book has three copies, 2 out and 1 in lib, i want my query to show all three copies. I think i am missing an outer join. Could you please clarify.
My tables that i use for this are
book_copy: book_no, isbn, on_loan
loan: student_id, book_no, duedate,datereturned,loan_id
fk: book_no with book_no in book_copy
book: isbn (pk), title, class
thanks, rk