当前位置:网站首页>sql concat() function
sql concat() function
2022-08-02 12:34:00 【m0_67400972】
1.concat()
The concat() function is used to concatenate two strings to form a single string
eg: employee_tbl
id
name
work_date
daily
1
John
2007-01-24
250
2
Ram
2007-05-27
270
sql:
SELECT CONCAT(id, name, work_date) FROM employee_tbl;Results:
CONCAT(id, name, work_date)
1John2007-01-24
2Ram2007-05-27
2.concat_ws()
How to use: concat_ws(separator,str2,str2,…)
concat_ws() stands for concat with separator, which is a special form of the concat() function.
The first parameter is the delimiter of other parameters, and the position of the delimiter should be placed between the positions where the two strings are concatenated.The separator can be a string or other parameters
Note: If the delimiter is NULL, the result is also NULL, and the function will ignore any NULL value after the delimiter parameter
eg:
select concat_ws(',','11','22','33');Results:
concat_ws(',','11','22','33')
11, 22, 33
eg:
select concat_ws(',','11','22',NULL);Results:
concat_ws(',','11','22',NULL)
11, 22
3.group_concat()
The complete syntax is as follows:
group_concat([DISTINCT] Field to concatenate [Order BY ASC/DESC sort field] [Separator 'separator'])
eg:
id
name
1
10
1
20
2
10
2
20
3
200
3
500
sql: group by id, print the value of the name field on one line, separated by semicolons
select id,group_concat(name separator ';') from aa group by id;Results:
id
name
1
10;20
2
10;20
3
200;500
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
- DTG-SSOD: The latest semi-supervised detection framework, Dense Teacher (with paper download)
- liunx基础命令讲解
- js semi-circle loading progress animation js special effects
- pgsql数据库实现导入导出
- 1.3快速生成树协议RSTP
- 手撸架构,Mysql 面试126问
- 以Boost为例的type3电压环补偿器实例
- 力扣209-长度最小的字符串——滑动窗口法
- Do you really understand the business process service BPass?
- Pod调度策略:亲和性、污点与污点容忍
猜你喜欢
随机推荐
智能图像分析-智能家用电器图像目标检测统计计数检测与识别-艾科瑞特科技(iCREDIT)
Four seasons of trees realized by svg
Object.entries()
Solve the problem of Chinese garbled characters in exporting excel file names
unique in numpy & pandas
FreeRTOS experiment -- delete task
np.nan, np.isnan, None, pd.isnull, pd.isna finishing and summary
技术分享| 融合调度系统中的电子围栏功能说明
svg实现的树木四季变化
第11章 文件
Likou 977-Squaring of ordered arrays - brute force method & double pointer method
linux basic command explanation
ssm访问数据库数据报错
1.3 Rapid Spanning Tree Protocol RSTP
SQL Server2019安装步骤及脱机安装Microsoft机器学习组件下一步不能继续的问题
Free Chinese-English Translation Software - Automatic Batch Chinese-English Translation Software Recommended Daquan
pytorch模型转tensorflow模型
Pod Scheduling Strategy: Affinity, Stain and Stain Tolerance
Hand rolled architecture, 41 Redis interview asked
FreeRTOS--优先级实验









