0

I have row 1 and 2 which they are similar in records except status column.

   +-----+------+-------+-----------+----------+---------+
| #id | NAME | STATUS|   c_lan   | Java_lan | Dot_lan |
+-----+------+-------+-----------+----------+---------+
|   1 |  A   |   111 |      yes  |    Q     | W       |
|   1 |  A   |   222 |      yes  |    Q     | W       |
|   2 |  B   |   333 |  NA       |    B     | C        |
+-----+------+-------+-----------+----------+---------+

Now is it possible to have these tow rows (1,2) become as one row as like below (need to merge status values in to one cell)?

+-----+------+-----------+-----------+----------+---------+
| #id | NAME | STATUS    |   c_lan   | Java_lan | Dot_lan |
+-----+------+-----------+-----------+----------+---------+
|   1 | A    |   111,222 |      yes  |    Q     | W       |
|   2 | B    |   333     |  NA       |    B     | C       |
+-----+------+-----------+-----------+----------+---------+

noting that i am considering this to be done on mysql view

Suhayb
  • 3,163
  • 3
  • 23
  • 30

1 Answers1

0

SELECT id,group_concat(distinct name),group_concat(distinct status),group_concat(distinct c_lan),group_concat(distinct java_lan),group_concat(distinct dot_lan) FROM table1 GROUP BY id;

PeterHe
  • 2,766
  • 1
  • 8
  • 7