I'm trying to update a field with a concated value of several rows.
so there is table a:
ID | single_value
1 | hello
2 | something
1 | world
42 | another someting
1 | bye bye
....
and table b:
ID | concated_field
1 | '' (i.e. empty )
2 | ''
3 | ''
4 | ''
as result, table b should be:
ID | concated_field
1 | hello, world, bye bye
2 | something
3 | ''
42 | another something
...
my query is:
update data.table b, data.content a
set b.concated_field= (
select group_concat(single_value separator ', ') from data.table
)
where b.ID= a.ID;
but my result is something like:
ID | concated_field
1 | hello, something, world,another something, bye bye
2 | ''
3 | ''
42 | ''
...
seems like the WHERE part is wrong but i don't get it. I am seriously looking for help!! :)