select
r.id,r.name,
le.level,
s.subject,
t.name as teacher_name,t.nickname
from table_register as r
inner join table_level as le on r.level=le.level
inner join table_subject as s on s.subject_Id=le.subject_id
inner join table_teacher as t on t.teacher_id=le.teacher_id
alias teacher.name ด้วย เพราะฟิลด์ซ้ำกับ register.name เป็น teacher_name
ผมเอาไปลองทำเป็นแบบนี้ถูกหรือเปล่าครับ
SELECT
table_register.id,table_register.name,
table_level.level,
table_subject.subject,
table_teacher.name as teacher_name,table_teacher.nickname,
from table_register as table_register
inner join table_level as table_level on table_register.level=table_level.level
inner join table_subject as table_subject on table_subject.subject_Id=table_level.subject_id
inner join table_teacher as table_teacher on table_teacher.teacher_id=table_level.teacher_id