I understand that this is necro, but the following is worth noting:
Both CONCAT and CONCAT_WS are pretty much equivalent.
However, the most noteworthy difference is that CONCAT may not return the expected results for cases when any of the inputs is NULL. In these cases, CONCAT will return NULL, while CONCAT_WS will skip NULL values ββand still return a string with the result of the remaining inputs. This means that in most cases, you probably want to use CONCAT_WS .
The following equivalents, unless one or more inputs are NULL:
// Result: LastName, FirstName, MiddleName CONCAT( LastName, ', ', FirstName, ', ', MiddleName ) // Result: LastName, FirstName, MiddleName CONCAT_WS( ', ', LastName, FirstName, MiddleName )
In cases where you want to use CONCAT_WS with different delimiters, just set the first entry to an empty line:
// Result: LastName, FirstName (MiddleName) CONCAT_WS( '', LastName, ', ', FirstName, ' (', MiddleName, ')' )