I have searched unsuccessfully for a satisfactory explanation on the difference between GROUP_CONCAT() and CONCAT_WS().
Are they as closely related as I think they are?
What are the differences in usage, speed, etc. between these two functions?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
GROUP_CONCATis used when you want to have non-NULL values from different column rows in a single row. For this you need to have GROUP BY to work.CONCAT_WSis to join two or more strings.Example,
GROUP_CONCAT(CONCAT_WS(' ', firstname, lastname) ORDER BY id ASC SEPARATOR ',');Outputs something like,
John Doe,Blah Blah,Tom Cruise,Lorem Ipsumhere space between the name is because of
CONCAT_WS,while whole result in one row is because of
GROUP_CONCAT