You ask help for what ? The title of the topic says that it has something to do with joining three tables , your message doesn't says anything like this.
First about the sql query:
Provide the data structure of your tables
Provide the criteria that you want the join to be done
Give example data of rows in tables and the outcome rows that you want to produce
About how to generate an html view of the rows of the outcome it has nothing to do with your first question. There are many tutorials here but if you have any SPECIFIC problem , describe it and we are here for you
Found and Answer:
Thanks to Jkon and Diafol.
I would redesign thse tables for efficiency,... I knew i would have to optmize and normalize those designs
Fortunately, i found an Article on Mysqli/Pivot with a good example: https://en.wikibooks.org/wiki/MySQL/Pivot_table
and guess what??? - i only needed one query and like you said those duplicates weren't necessary. I only needed the enrol table to do that and Get Names of the students from the students table
This was the code i ran:
$sql = "select student_id,\n"
. "sum(exam*(1-abs(sign(subject_id-1)))) as english,\n"
. "sum(exam*(1-abs(sign(subject_id-2)))) as Mathematics,\n"
. "sum(exam*(1-abs(sign(subject_id-3)))) as Agric\n"
. "from enrol WHERE class_id=1 group by student_id";
I am still reading on Pivot table and Cross Tab anyway. There seems to be powerful possibilities there.