Skip to content

Instantly share code, notes, and snippets.

@jsntn
Created May 8, 2014 04:22
Show Gist options
  • Save jsntn/993977ebfb7f524155ce to your computer and use it in GitHub Desktop.
Save jsntn/993977ebfb7f524155ce to your computer and use it in GitHub Desktop.
-- 连接后以逗号分隔
mysql> select concat_ws(',','11','22','33');
+-------------------------------+
| concat_ws(',','11','22','33') |
+-------------------------------+
| 11,22,33 |
+-------------------------------+
1 row in set (0.00 sec)
-- 和MySQL中concat函数不同的是, concat_ws函数在执行的时候,不会因为 NULL 值而返回 NULL
mysql> select concat_ws(',','11','22',NULL);
+-------------------------------+
| concat_ws(',','11','22',NULL) |
+-------------------------------+
| 11,22 |
+-------------------------------+
1 row in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment