0
我有2個表。第一個表格包含大量的用戶數據。第二個表格包含一個類別列表,以及這些位置是否已填滿。mySQL表上的多個連接
我需要顯示類,用戶名和用戶名。
我試過做「連接」 - 但名稱似乎只是相互覆蓋,所以我只得到每行一個名稱。
用戶表:
+----------+---------+
| user_ID | name |
+----------+---------+
| 1 | Smith |
+----------+---------+
| 2 | Jones |
+----------+---------+
| 3 | Tim |
+----------+---------+
etc
Class表:
+-------------+--------+--------+--------+---+---------+
| class_date | Spot 1 | Spot 2 | Spot 3 | . | Spot 16 |
+-------------+--------+--------+--------+---+---------+
| 2012/1/1 | 1 | 4 | 8 | . | 5 |
+-------------+--------+--------+--------+---+---------+
| 2012/2/1 | 2 | NULL | 1 | . | 3 |
+-------------+--------+--------+--------+---+---------+
| 2012/3/1 | 3 | 7 | NULL | . | NULL |
+-------------+--------+--------+--------+---+---------+
我想達到的目標:
+-------------+-------------+------------+--------------+---+------------+
| class_date | Spot 1 | Spot 2 | Spot 3 | . | Spot 16 |
+-------------+-------------+------------+--------------+---+------------+
| 2012/1/1 | 1 - Smith | 4 - Ben | 8 - Drew | . | 5 - Loz |
+-------------+-------------+------------+--------------+---+------------+
| 2012/2/1 | 2 - Jones | NULL | 1 - Smith | . | 3 - Tim |
+-------------+-------------+------------+--------------+---+------------+
| 2012/3/1 | 3 - Tim | 7 - Dan | NULL | . | NULL |
+-------------+-------------+------------+--------------+---+------------+
任何幫助將不勝感激