the following SQL is returning every BT.Bt_Name
where L.date_back
is Null. I only wish to select the BT.Bt_Name
s where L.Bc_id
is duplicated
SELECT BT.Bt_Name
FROM Book_Title BT INNER JOIN (
Book_Copy BC INNER JOIN Loan L ON BC.Bc_id = L.Bc_id
) ON BT.Bt_id = BC.Bt_id
WHERE L.Date_back Is NULL
GROUP BY BT.Bt_name
HAVING COUNT(L.Bc_id) >1;
Is it the joins which are causing COUNT(L.Bc_id)
to be >1 for all records where L.Date_back
Is NULL? FYI only one should be returned (deliberate input error).