Note that there are some explanatory texts on larger screens.

plurals
  1. POnot listing users when using innerjoin with max in php mysql
    text
    copied!<p>i am new in php i have a problem in my php code.please help me.. i have two tables</p> <p> </p> <pre><code>seeker seeker_nic-----username 111-------------ali 222-------------umer 333-------------raza </code></pre> <p><br>`</p> <pre><code>requestblood id-------seeker_nic-----requireddate 1------- 111 ----------2012/9/9 2 ------- 222-----------2012/5/8 3 ------ 111-----------2012/10/11 4 ------- 111-----------2012/11/12 5 ------- 222-----------2012/7/9 6 ------- 333 ----------2012/4/4 </code></pre> <p>now i want to list users one time with maximum date like..</p> <pre><code>s.no---- username----- requireddate 1------- ali---------- 2012/11/12 2------- umer--------- 2012/7/9 3------- raza--------- 2012/4/4 </code></pre> <p>i am using this query</p> <pre><code>"SELECT bloodrequest.requireddate, seeker.username FROM bloodrequest JOIN seeker ON bloodrequest.seeker_nic= seeker.seeker_nic Join (SELECT max(requireddate)as maxdate FROM bloodrequest) maxresults on bloodrequest.requireddate = maxresults.maxdate" </code></pre> <p>.. but it shows only 1 record not the list and if use this query (left join instead of join)</p> <pre><code>"SELECT bloodrequest.requireddate, seeker.username FROM bloodrequest left JOIN seeker ON bloodrequest.seeker_nic = seeker.seeker_nic left join (SELECT max(requireddate)as maxdate FROM bloodrequest) maxresults on bloodrequest.requireddate = maxresults.maxdate"; </code></pre> <p>then it shows all records with all dates but not tha maximum..</p> <pre><code>id------seeker_nic -------requireddate&lt;br&gt; 1 ------ ali --------- 2012/9/9&lt;br&gt; 2 ------ ali ---------- 2012/10/11&lt;br&gt; 3 ------ ali ------------ 2012/11/12&lt;br&gt; 4------ umer------------- 2012/5/8&lt;br&gt; 5------- umer -------------2012/7/9&lt;br&gt; 6 ------ raza--------------2012/4/4&lt;br&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload