CONCAT()
CONCAT_WS()
GROUP_CONCAT()
CONCAT(string1,string2)
最常用的字符串拼接方法,但遇到拼接中的字符串出现null的情况会返回null
root@((none))11:33:50>select CONCAT(TABLE_SCHEMA,TABLE_NAME) from information_schema.TABLES limit 3;
+---------------------------------------------------------+
| CONCAT(TABLE_SCHEMA,TABLE_NAME) |
+---------------------------------------------------------+
| information_schemaCHARACTER_SETS |
| information_schemaCOLLATIONS |
| information_schemaCOLLATION_CHARACTER_SET_APPLICABILITY |
+---------------------------------------------------------+
3 rows in set (0.01 sec)
CONCAT_WS(separator,str1,str2,…)
多了分隔符功能
root@((none))11:33:53>select CONCAT_WS(".",TABLE_SCHEMA,TABLE_NAME) from information_schema.TABLES limit 3;
+----------------------------------------------------------+
| CONCAT_WS(".",TABLE_SCHEMA,TABLE_NAME) |
+----------------------------------------------------------+
| information_schema.CHARACTER_SETS |
| information_schema.COLLATIONS |
| information_schema.COLLATION_CHARACTER_SET_APPLICABILITY |
+----------------------------------------------------------+
3 rows in set (0.00 sec)
group_concat( [DISTINCT] 连接的字段 [Order BY 排序字段 ASC/DESC] [Separator ‘分隔符’] )
连接字段,多个值显示为一行.连接的可以是多个字段,也可以对连接字段进行排序
root@((none))11:44:27>select GROUP_CONCAT(TABLE_SCHEMA,TABLE_NAME) from information_schema.TABLES limit 3 \G;
*************************** 1. row ***************************
GROUP_CONCAT(TABLE_SCHEMA,TABLE_NAME): information_schemaCHARACTER_SETS,information_schemaCOLLATIONS,information_schemaCOLLATION_CHARACTER_SET_APPLICABILITY,information_schemaCOLUMNS,information_schemaCOLUMN_PRIVILEGES,information_schemaENGINES,information_schemaEVENTS,information_schemaFILES,information_schemaGLOBAL_STATUS,information_schemaGLOBAL_VARIABLES,information_schemaKEY_COLUMN_USAGE,information_schemaOPTIMIZER_TRACE,information_schemaPARAMETERS,information_schemaPARTITIONS,information_schemaPLUGINS,information_schemaPROCESSLIST,information_schemaPROFILING,information_schemaREFERENTIAL_CONSTRAINTS,information_schemaROUTINES,information_schemaSCHEMATA,information_schemaSCHEMA_PRIVILEGES,information_schemaSESSION_STATUS,information_schemaSESSION_VARIABLES,information_schemaRDS_INDEX_HINTS_INFO,information_schemaSTATISTICS,information_schemaTABLES,information_schemaTABLESPACES,information_schemaTABLE_CONSTRAINTS,information_schemaTABLE_PRIVILEGES,information_schemaTRIGGERS,information_schemaUSER_PRIVILEGES,information_schemaVIEWS,information