<div dir="ltr"><div><div><div>Hello all,<br><br></div>Could someone please help me in creating the SQL query to get all the holds in the library for which the book is available,in the library (i.e, no issue exists for that book)<br><br></div>The reserves table contains some rows for which  itemnumber is Null, and the waitingdate is Null for every row even if no issue exists for the item.<br><br></div><div>I came up with the following sql query, but I am not sure if I am right, can someone please verify my query, or rectify it with the correct query:</div><div><br></div><div>      ```<font size="1"><span style="font-family:verdana,sans-serif">SELECT<br>         borrowers.surname, borrowers.email, borrowers.cardnumber, items.barcode, biblio.title, reserves.reservedate<br>      FROM reserves<br>      LEFT JOIN borrowers USING (borrowernumber)<br>      LEFT JOIN items USING (itemnumber)<br>      LEFT JOIN biblio ON (reserves.biblionumber = biblio.biblionumber)<br>      WHERE<br>          (reserves.itemnumber IS NOT NULL<br>          AND NOT EXISTS(SELECT issue_id FROM issues WHERE items.itemnumber = issues.itemnumber)<br>          )<br>          OR<br>          (reserves.itemnumber IS NULL<br>          AND EXISTS(<br>              SELECT itemnumber FROM items i2 WHERE items.biblionumber=reserves.biblionumber<br>              AND NOT EXISTS(<br>                  SELECT issue_id FROM issues WHERE issues.itemnumber=i2.itemnumber<br>                  )<br>              )   <br>          )</span></font></div><div style="margin-left:40px">```</div><div style="margin-left:40px"><br></div><div>Thanks in advance</div><div>Regards<br></div><div><div><div><div><div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font style="font-size:12.8px" face="georgia, serif"><b>Raghav Arora</b></font><div style="font-size:12.8px"><font face="georgia, serif">Sophomore, M.Sc (Hons) Chemistry BE Electrical and Electronics Engineering</font></div><div style="font-size:12.8px"><font face="georgia, serif">Contact : (+91) 9897597761</font></div><div style="font-size:12.8px"><font face="georgia, serif"><a href="mailto:raghavarora999@yahoo.in" rel="noreferrer" style="color:rgb(17,85,204)" target="_blank">Personal Email</a> | <a href="mailto:f20171016@pilani.bits-pilani.ac.in" rel="noreferrer" style="color:rgb(17,85,204)" target="_blank">University Email</a><br></font></div><div style="font-size:12.8px"><a href="https://www.linkedin.com/in/raghav-arora-9820a648/" rel="noreferrer" style="color:rgb(17,85,204)" target="_blank">LinkedIn</a> |  <a href="https://github.com/RAraghavarora/" target="_blank">GitHub</a> <br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div><font color="#888888"><span style="font-size:10pt;color:rgb(253,175,23)">▄▄▄▄▄▄▄▄▄▄▄▄</span><span style="font-size:10pt;color:rgb(117,195,233)">▄▄▄▄▄▄▄▄▄▄▄▄▄</span><span style="font-size:10pt;color:rgb(237,27,36)">▄▄▄▄▄▄▄▄▄▄▄▄</span></font></div></div><div style="font-size:12.8px"><div><font color="#666666"><b>Birla Institute of Technology and Science, Pilani</b></font></div><div><font color="#666666">Pilani campus,</font></div><div><span style="color:rgb(102,102,102)">Rajasthan-333031</span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>