当前位置:网站首页>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
边栏推荐
- Custom mvc framework review
- Import and export data of SQL Server database
- Likou 35 - search for insertion position - binary search
- SQL Server2019安装步骤及脱机安装Microsoft机器学习组件下一步不能继续的问题
- 手撸架构,MongDB 面试50问
- Thymeleaf
- 用位运算为你的程序加速
- The ex-boyfriend bought chili water and threatened to rob his daughter. Can the woman apply for a personal safety protection order?
- Seneor曝光基础知识
- MyCat2 introduction and installation and basic use
猜你喜欢
Likou 209 - String with the Minimum Length - Sliding Window Method
js半圆环加载进度动画js特效
基础协议讲解
Basic protocol explanation
Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单。
MyCat2的介绍与安装以及基本使用
Likou 58 - Left Rotation String
1.3 Rapid Spanning Tree Protocol RSTP
Likou 704 - binary search
np.nan, np.isnan, None, pd.isnull, pd.isna finishing and summary
随机推荐
基础协议讲解
数据湖(三):Hudi概念术语
SQL Server 数据库之导入导出数据
Likou 977-Squaring of ordered arrays - brute force method & double pointer method
力扣704-二分查找
手撸架构,Mysql 面试126问
Do you really understand the business process service BPass?
zabbix automated monitoring script
PHP伪协议详解
pytorch模型转tensorflow模型
WPF——自定义日历
手撸架构,MongDB 面试50问
Hand rolled architecture, 41 Redis interview asked
Import and export data of SQL Server database
MyCat2的介绍与安装以及基本使用
FreeRTOS--stack experiment
Process finished with exit code 1
SQL Server 2019安装错误0x80004005 服务没有及时响应启动或控制请求详细解决方法
np.nan, np.isnan, None, pd.isnull, pd.isna finishing and summary
如何更好评估信用贷风险?看这场评分卡模型直播就可以了