我在MySQL(MariaDB)中有这两个表:
表数据
+------+------+
|id |object|
+------+------+
|1 |AFD |
+------+------+
|2 |AFG |
+------+------+
|3 |ASD |
+------+------+
|4 |BDS |
+------+------+
|5 |BDF |
+------+------+
表格工作
+------+------+
|id |action|
+------+------+
|1 |34 |
+------+------+
|1 |54 |
+------+------+
|1 |65 |
+------+------+
|2 |73 |
+------+------+
|2 |11 |
+------+------+
对于表DATA中的每个ID,表WORK中都有多个ID。 我需要这样的输出:
+------+------+-------+-------+-------+
|id |object|action1|action2|action3|
+------+------+-------+-------+-------+
|1 |AFD |34 |54 |64 |
+------+------+-------+-------+-------+
|2 |AFG |73 |11 |NULL |
+------+------+-------+-------+-------+
...
谢谢。