CONCAT() และ CONCAT_WS() ใช้รวมสตริง 2 ตัวขึ้นไป แตแตกต่างกันที่: CONCAT_WS() รวมพร้อมตัวคั่น (separator) ระหว่างสตริง ส่วน CONCAT() ไม่มีแนวคิดตัวคั่น อีกความแตกต่าง: CONCAT() คืน NULL หากอาร์กิวเมนต์ใดเป็น NULL ส่วน CONCAT_WS() คืน NULL ก็ต่อเมื่อ ตัวคั่นเป็น NULL
ตัวอย่าง
ตัวอย่างแสดงความแตกต่าง:
mysql> SELECT CONCAT('Ram','is','a','good','student') AS 'Example of CONCAT()';
+---------------------+
| Example of CONCAT() |
+---------------------+
| Ramisagoodstudent |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT CONCAT_WS(' ','Ram','is','a','good','student') AS 'Example of CONCAT_WS()';
+------------------------+
| Example of CONCAT_WS() |
+------------------------+
| Ram is a good student |
+------------------------+
1 row in set (0.00 sec)