简体   繁体   中英

MariaDB GROUP_CONCAT only returns one value

I am experiencing a strange issue with the GROUP_CONCAT function in my instance, where using it to group together integers works just fine, but applying it to a varchar doesn't work at all.

The data is along the lines of:

CUSTOMERID  LOCATIONNAME    PRODUCTID   UNITS   ID  PRODUCTNAME
1           Location            65       100    1   Product 65
1           Location            66       100    2   Product 66
1           Location            67       100    3   Product 67
1           Location            68       100    4   Product 68
1           Location            68       100    5   Product 68

When I run: SELECT GROUP_CONCAT(DISTINCT lm.ProductID) as Brand FROM locationMap lm WHERE (lm.CustomerID = 1);

It returns 65, 66, 67, 68 and works properly.

When I run: SELECT GROUP_CONCAT(DISTINCT lm.ProductName) as Brand FROM locationMap lm WHERE (lm.CustomerID = 1);

It returns only the first item (Product 65).

I set up an SQL Fiddle ( http://www.sqlfiddle.com/#!2/2392f/3 ) to test it out, and everything functions properly there. Can anyone offer a suggestion for what might be wrong in my environment that would cause this? I'm running 5.5.30-MariaDB-30.1

Verified that upgrading the server from 5.5.30-MariaDB-30.1 to 5.5.38-MariaDB-35.2 has resolved this issue. Thanks to everyone for their suggestions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM