Help with Table Joins

I am trying to join three mysql tables with not much success.

I have three tables:

student
--------
id
school
teacher

--------
school
--------
id
school_name

--------
teacher
--------
id
teacher_name

I thought that something like this would work:

SELECT *
    FROM student AS stu
    INNER JOIN
        school AS sch on (stu.school = sch.id)
    INNER JOIN
        teacher AS tea on (stu.teacher = tea.id)

The first inner join works but as soon as I add the second join the server connect output only shows the first record.

Try LEFT JOIN instead of INNER JOIN

Setting as LEFT JOIN doesn’t display any results from the third table (teacher). Records are showing as null.

Records from the first two tables are showing the correct data.

Hi,
In the past I have had some problems when all joined table rows had the name of id.
Please try with different id row names, like:
studentid
schoolid
teacherid
and so on.
I don’t know why, but it solved it for me.

Thanks, I tried this as I also thought that might be the issue but it hasn’t made any difference.

It works for me