我正在做一個項目在MySQL中。我遇到一個問題join
。複雜的連接只能選擇兩個主題
+---+-----------+-----------+
|id | name | elective |
+---+-----------+-----------+
| 1 | Jone | Math |
| 2 | Jane | Math |
| 3 | Doe | Math |
| 4 | Bloggs | Math |
| 5 | Peter | Math |
| 6 | Chris | Math |
| 7 | Mark | Math |
| 3 | Doe | Physics |
| 4 | Bloggs | Physics |
| 5 | Peter | Physics |
| 6 | Chris | Physics |
| 7 | Mark | Physics |
| 5 | Peter | Chemistry |
| 6 | Chris | Chemistry |
| 7 | Mark | Chemistry |
+---+-----------+-----------+
在上表中,很少有人選擇了兩個以上的科目,其他人只有兩個科目。而其他人只選擇了一個主題。
但我只想顯示第二個,即只有兩個主題的人。這我想要使用內部連接。
爲什麼有人會毀了我的一個很好的編輯?現在看起來很糟糕。 –
請修復表格結構。這個數據可以用多於一種方式解釋:( –