1

I have this two tables in MySQL (MariaDB):

Table DATA

+------+------+
|id    |object|
+------+------+
|1     |AFD   |
+------+------+
|2     |AFG   |
+------+------+
|3     |ASD   |
+------+------+
|4     |BDS   |
+------+------+
|5     |BDF   |
+------+------+

Table WORK

+------+------+
|id    |action|
+------+------+
|1     |34    |
+------+------+
|1     |54    |
+------+------+
|1     |65    |
+------+------+
|2     |73    |
+------+------+
|2     |11    |
+------+------+

To every id in table DATA there are several id's in table WORK. I need to get the output like this:

+------+------+-------+-------+-------+
|id    |object|action1|action2|action3|
+------+------+-------+-------+-------+
|1     |AFD   |34     |54     |64     |
+------+------+-------+-------+-------+
|2     |AFG   |73     |11     |NULL   |
+------+------+-------+-------+-------+
...

Thank you in advance.

Rick James
  • 135,179
  • 13
  • 127
  • 222
culter
  • 5,487
  • 15
  • 54
  • 66

0 Answers0