Name

CONCAT_WS()

Synopsis

CONCAT_WS(separator, str1, str2, ...)

This works in the same way as CONCAT except it inserts a separator between the items being concatenated. If the separator is NULL the result will be NULL, but NULL values can be used as other arguments, which will then be skipped. This code returns the string “Truman,Harry,S”:

SELECT CONCAT_WS(',' 'Truman', 'Harry', 'S');

Get Learning PHP, MySQL, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.