Jump to content

Help On Doing A Outer Join On Three Tables.


talk2toyin

Recommended Posts

I need to disply each logged on pupil's result to the pupil. I have three tables(a and B). Table 'a' is related to table 'b' by c_id....while table 'b' is related to an 'id' column in a different table. I need to display a list of all the courses, and scores in table 'a' and 'b' even if a score hasn't been assigned to any of the courses. Here's my source code:

 

$sql = "SELECT * FROM a

LEFT JOIN b ON a.c_id = b.c_id

WHERE b.stud_id = '$stud_id'

ODERE BY a.c_code";

 

$res = mysql_query($sql);

$nrows =mysql_num_rows($res);

 

for($i=0;$i<$nrows;$i++) {

//my output display loop goes in here.

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.