我三個表MySQL的加入了特定的行只
意見表
---------------------------------------------------------------------------
id | commented_by | comment | commented_by
---------------------------------------------------------------------------
1 | asdf156df5s4fd | student comment | student
2 | klsdfjklsdfno | student comment | student
3 | jafkadfjlkdnvwa | teacher comment | teacher
4 | adsjflandsfinndfs | student comment | student
5 | dsf5614dsf8wef4 | teacher comment | teacher
---------------------------------------------------------------------------
老師表
id | teacher_id | teacher_name | teaches
---------------------------------------------------------------------------
1 | jafkadfjlkdnvwa | abc cde | maths
2 | dsf5614dsf8wef4 | egc kjl | science
.
.
.
---------------------------------------------------------------------------
學生表
id | student_id | student_name |
---------------------------------------------------------------------------
1 | asdf156df5s4fd | student_1 |
2 | klsdfjklsdfno | student_2 |
3 | adsjflandsfinndfs | student_3 |
.
.
---------------------------------------------------------------------------
現在,我們希望是mysql join
可能返回這樣的事情
id | comment_id | comment_by | name | teaches
---------------------------------------------------------------------------
1 | asdf156df5s4fd | student | student_1 | null
2 | klsdfjklsdfno | student | student_2 | null
3 | jafkadfjlkdnvwa | teacher | abc cde | maths
4 | adsjflandsfinndfs | student | student_3 | null
5 | dsf5614dsf8wef4 | teacher | egc kjl | science
---------------------------------------------------------------------------
無法找到,我們可以用笨的活動記錄實現這一目標的精確查詢
你可以發佈的東西一些代碼,你tryed?順便嘗試看看這個鏈接:http://stackoverflow.com/questions/15219132/displaying-data-of-two-tables-on-the-same-web-page – boroboris
你將不得不提供更多的信息關於你在這裏嘗試做。我個人並不瞭解你如何從這三張表中獲得這些結果。 – WillardSolutions
@EatPeanutButter基本上是一個帖子裏,我們要展示的意見,但與老師批語它要包括他們所教科目,但不適合學生 – runningmark