php - Trying to debug INNER JOIN cannundrum -
i using smaller function try , debug bigger function's inner join. novice has little experience of using joins. in fact, i've started trying use inner-joins two/three days ago first experience of joins. smaller function follows:
$data3 = '\'' . implode('\', \'', $posted_email) . '\''; echo "post email var dump: "; var_dump($posted_email); $exam_recordation = mysql_query("select student_email exam partner_id in (select partner_id exam student_email = $data3) , student_email <> $data3"); echo "<br>recordation query: "; echo "select student_email exam partner_id in (select partner_id exam student_email = $data3) , student_email <> $data3"; echo "<br>recordation var dump: "; var_dump($exam_recordation); echo "<table border=='1'> <tr> <th>name</th> </tr>"; while ($fetch_record = mysql_fetch_array($exam_recordation)) { echo "<tr>"; echo "<td>" . $fetch_record['student_email'] . "</td>"; echo "</tr>"; } echo "</table>"; //inner join should use email of partner out of $exam query find name , print $name_query = mysql_query("select distinct student.name student inner join exam on student.email = exam.student_email student.email = $exam_recordation[student_email]"); echo "<br><br>inner join query: "; echo "select distinct student.name student inner join exam on student.email = exam.student_email student.email = $exam_recordation[student_email]"; echo "<br>query result dump: "; var_dump($name_query);
the result of follows:
post email var dump: array 'student_email' => string 'nuts@prof.com' (length=13) recordation query: select student_email exam partner_id in (select partner_id exam student_email = 'nuts@prof.com') , student_email <> 'nuts@prof.com' recordation var dump: resource(6, mysql result) name foiling@gorilla.com inner join query: select distinct student.name student inner join exam on student.email = exam.student_email student.email = query result dump: boolean false
where problem ask? in inner join cannot figure out why not take email $exam_recordation query though picked in table. in bigger function, have inner join working recordation query in while loop produce hope desired effects. i've been struggling problem while , since attempts fix/ask fix main function whole have failed, thought i'd try inner join question seems main culprit head banging against brick walls.
$exam_recordation = mysql_query("select student_email exam partner_id in (select partner_id exam student_email = $data3) , student_email <> $data3"); echo "<br>recordation query: "; echo "select student_email exam partner_id in (select partner_id exam student_email = $data3) , student_email <> $data3"; echo "<br>recordation var dump: "; var_dump($exam_recordation); echo "<table border=='1'> <tr> <th>name</th> </tr>"; while ($fetch_record = mysql_fetch_array($exam_recordation)) { echo "<tr>"; echo "<td>" . $fetch_record['student_email'] . "</td>"; echo "</tr>"; }
$name_query = mysql_query("select distinct student.name student inner join exam on student.email = exam.student_email student.email = $exam_recordation[student_email]");
see here, fetching query variable $fetch_record, later using $exam_recordation, mysql query resource, not fetched data.
Comments
Post a Comment