MySQL: Introduction to CONCAT and CONCAT_WS Functions

MySQL supports two types of concatenation functions: CONCAT and CONCAT_WS.

CONCAT function contatenates all the argument values like:


This returns the folowing:


If you want to concatenate with a comma, specify the comma at the end of each value then pass it as an argument:

SELECT CONCAT('Television,','Mobile,','Furniture');
SELECT CONCAT('Television',',','Mobile',',','Furniture');

This will return the following:


You can omit the extra work by using CONCAT_WS function. CONCAT_WS means concatenate with separator. This is similar to CONCAT function but accepts the separator as the first argument.

Read the rest of the tutorial here:

Leave a Reply

Your email address will not be published. Required fields are marked *