SELECT
teacher.teacher_id,
teacher.teacher_name,
work.work_id,
work.work_Teacher_1,
work.work_Teacher_2,
work.work_day
FROM
teacher
Inner Join work ON work.work_Teacher_1 = teacher.teacher_id AND work.work_Teacher_2 = teacher.teacher_id
เวลาดูผลลัพธ์แล้วข้อมูลไม่ขึ้นครับ
ขอมูลที่ผมต้องการให้แสดงคือ
work day 1 มีอาจารย์ 2 ท่านทำงานคือใครบ้าง ครับ
ขอบคุณครับ
Tag : PHP
Date :
2015-07-03 16:24:04
By :
keng_ds
View :
735
Reply :
7
No. 1
Guest
ไม่รู้ถูกหรือเปล่านะครับ ลองรันดู
Code (SQL)
SELECT work.work_id, work.work_Teacher_1, teacher_1.teacher_name AS teacher_1_name, work.work_Teacher_2, teacher_2.teacher_name AS teacher_2_name, work.work_day
FROM work JOIN teacher AS teacher_1 ON work.work_Teacher_1 = teacher_1.teacher_id
JOIN teacher AS teacher_2 ON work.work_Teacher_2 = teacher_2.teacher_id
SELECT work_day,t2.teacher_name,t3.teacher_name
FROM `work` t1 left join teacher t2 on work_teacher_id1 = t2.teacher_id
left join teacher t3 on work_teacher_id2 = t3.teacher_id