<div dir="auto"><div>It's a left outer join, which means we will get all the applicable rows from reserves but not necessarily from issues. If there isn't a matching row in issues then we get null values instead. The date_due column should never be null otherwise.</div><div dir="auto"><br></div><div dir="auto">So that query should show reserves with no issue.</div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Wed, Jun 26, 2019, 10:50 PM RAGHAV ARORA <<a href="mailto:f20171016@pilani.bits-pilani.ac.in">f20171016@pilani.bits-pilani.ac.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Thank you for your reply Sir.<br><br></div>Why are we querying for issues that have Null date_due? Should we not query for the reserves corresponding to which no issues exist.<br></div><br></div>When will the date_due be null?<br></div><div><br></div><div>Regards,</div><div><div><div><div><div><div><div dir="ltr" class="m_6064354495704771391gmail_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 noreferrer" style="color:rgb(17,85,204)" target="_blank">Personal Email</a> | <a href="mailto:f20171016@pilani.bits-pilani.ac.in" rel="noreferrer 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 noreferrer" style="color:rgb(17,85,204)" target="_blank">LinkedIn</a> |  <a href="https://github.com/RAraghavarora/" target="_blank" rel="noreferrer">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><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 26, 2019 at 10:44 PM Michael Hafen <<a href="mailto:michael.hafen@washk12.org" target="_blank" rel="noreferrer">michael.hafen@washk12.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Here's me trying the query with more joins instead of sub-selects, though I can't guarantee it's exactly what you want.</div><div><br></div><div>SELECT borrowers.surname, borrowers.email, borrowers.cardnumber, it1.barcode, biblio.title, reserves.reservedate</div><div> FROM reserves</div><div> LEFT JOIN borrowers USING (borrowernumber)</div><div> LEFT JOIN biblio USING (biblionumber)</div><div> LEFT JOIN items AS it1 USING (itemnumber)</div><div> LEFT JOIN issues AS iss1 USING (itemnumber)</div><div> LEFT JOIN items AS it2 ON (reserves.biblionumber = it2.biblionumber)</div><div> LEFT JOIN issues AS iss2 ON(it2.itemnumber = iss2.itemnumber)</div><div>WHERE iss1.date_due IS NULL AND iss2.date_due IS NULL</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 26, 2019 at 12:45 AM RAGHAV ARORA <<a href="mailto:f20171016@pilani.bits-pilani.ac.in" target="_blank" rel="noreferrer">f20171016@pilani.bits-pilani.ac.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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="m_6064354495704771391gmail-m_5968804868364671210gmail-m_-2586321856451405293gmail_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 noreferrer" style="color:rgb(17,85,204)" target="_blank">Personal Email</a> | <a href="mailto:f20171016@pilani.bits-pilani.ac.in" rel="noreferrer 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 noreferrer" style="color:rgb(17,85,204)" target="_blank">LinkedIn</a> |  <a href="https://github.com/RAraghavarora/" target="_blank" rel="noreferrer">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>
_______________________________________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org" target="_blank" rel="noreferrer">Koha-devel@lists.koha-community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer noreferrer" target="_blank">http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
website : <a href="http://www.koha-community.org/" rel="noreferrer noreferrer" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" rel="noreferrer noreferrer" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer noreferrer" target="_blank">http://bugs.koha-community.org/</a></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="m_6064354495704771391gmail-m_5968804868364671210gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div>Michael Hafen<br></div>Washington County School District Technology Department<br></div>Systems Analyst<br><br></div></div></div></div>
</blockquote></div>
</blockquote></div></div></div>