May 2005
Intermediate to advanced
352 pages
14h 39m
English
CONCAT_WS( )
CONCAT_WS(separator,string, . . . )
This function combines strings of text and columns together with a separator specified in the first argument. Any number of strings may be specified after the first argument, with each argument separated by a comma. Null values are ignored.
SELECT CONCAT_WS('|', student_id, name_last, name_first)
AS 'student_record'
FROM students LIMIT 3;
+-----------------------------+
| student_record |
+-----------------------------+
| 433342000|Dyer|Russell |
| 434892001|Dyer|Marie |
| 433892002|Zabalaoui|Michael |
+-----------------------------+Here the vertical bar is used to separate the columns. This function can be useful for exporting data to formats acceptable to other software. However, you will require some programming to export the data to an external file using an SQL statement such as this one.
Read now
Unlock full access