Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in SQL by (20.3k points)

Basically, the question is how to get from this:

id    string

1          A

1          B

2          C

to this:

id    string

1          A B

2          C

1 Answer

0 votes
by (40.7k points)

Try this code:

SELECT id, GROUP_CONCAT(string SEPARATOR ' ') FROM table GROUP BY id;

You can refer to this link http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

GROUPCONCAT: This function returns a string result with the concatenated non-NULL values from the group. This returns NULL if there are no non-NULL values.

Related questions

0 votes
1 answer
asked Jul 23, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...