Again join problem

i have the next data in 3 tables:

  1. Table: Student
    fields: id / name / age

2)Table: subject
fields: id/name (math, history, english)

3)Table: mark
fields: student_id / subject_id / mark

I need table the will show me: student name / age / Exam subject and marks for each one.
Please Please i try few hours to understand the join and on and i success with 2 tables but have no idea how to do this with 3.
please help

I have already shown you how to do this.
in this thread .
http://www.phphelp.com/forum/index.php?topic=17456.0
why make another thread with the same question?

Hi,

what appears to be the problem?
Looks to me like a simple:

SELECT (the fields you want) FROM (the tables they're in) WHERE (conditions and links) should do the trick.

Doesn’t this get what you want?

SELECT student.name, student.age, subject.name, mark.mark 
FROM student, subject, mark 
WHERE mark.student_id = student.id AND 
      subject.id = mark.subject_id 
ORDER BY student.id

hope it helps, ;D
O.

The answer before was perfect but the table name in the example wasnot like mine and its give me some trubly even if this is very stupid.
By the way i try the 2 examples and now finally i understand this system even with join command.

** i found small Problem.
I have student tom that have 1 mark in math
and 1 mark in english
but when i try to print it its shows me like
TOM MATH 75
TOM ENGLISH 65
TOME HISTORY 98
i want that this will be in the next format: like TOM / MATH: 75 / ENGLISH: 65 / HISTORY:98 how to do this?

use html to do your formating

Sponsor our Newsletter | Privacy Policy | Terms of Service