Patrick Vuarnoz writes:
> Hi there,
>
> I have a problem with concatening strings using "GROUP BY". So what I
> want to do is something like this:
>
> ---------------------------------------------------
> SELECT CONCAT(mystring) FROM testtable GROUP BY id;
>
> on a testtable like:
> mystring VARCHAR(255)
> id INT(11)
> ---------------------------------------------------
>
> What I've found on the documentation is, that you can sum up numbers
> with "SUM()" using "GROUP BY". The main question now is: is there a
> possibility to do the same on CHAR and VARCHAR fields ??
>
>
> My MySql Version is: Ver 9.36 Distrib 3.22.27, for pc-linux-gnu (i686)
>
> Does anybody know a possibility to solve my problem ? - Thanks.
Hi!
You can run this:
select id, concat(mysqltring,....) from testtable group by id;
But, if you want to concat all strings for the same value of id, that
is not possible !!!
Anyway, what sense would it make ??
If mystring contains only number chars, you could use SUM(mystring +
0).
Regards,
Sinisa
+----------------------------------------------------------------------+
| TcX ____ __ _____ _____ ___ == mysql@stripped |
| /*/\*\/\*\ /*/ \*\ /*/ \*\ |*| Sinisa Milivojevic |
| /*/ /*/ /*/ \*\_ |*| |*||*| mailto:sinisa@stripped |
| /*/ /*/ /*/\*\/*/ \*\|*| |*||*| Larnaka, Cyprus |
| /*/ /*/ /*/\*\_/*/ \*\_/*/ |*|____ |
| ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^ |
| /*/ \*\ Developers Team |
+----------------------------------------------------------------------+