is it possible to have distinct + concat within group_concat?
I have this开发者_Python百科, as part of a bigger query:
CAST( GROUP_CONCAT( c.fname) AS char ) AS fname
, CAST( GROUP_CONCAT( c.lname ) AS char ) AS lname
I want something like:
CAST( GROUP_CONCAT( DISTINCT concat(c.fname,' ',c.lname) ) AS char ) AS user
Means, first I want to concat first name and last name, and then use the distinct to check whether the same firstname / lastname combination is not getting repeated. Possible using mysql or should I have to do that after using php?
Thanks guys.
I made a test with some of my tables, and it worked for me:
SELECT GROUP_CONCAT(DISTINCT CONCAT(id,nombre)) FROM pre_departamento;
精彩评论