当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
js true 3d histogram plugin
The 7 most commonly used data analysis thinking, solve 95% of the analysis problems
js真3d柱状图插件
Seneor曝光基础知识
Likou 704 - binary search
pgsql数据库实现导入导出
Technology sharing | Description of the electronic fence function in the integrated dispatching system
PHP伪协议详解
The use of QListView
js semi-circle loading progress animation js special effects
JVM学习----垃圾回收调优
测试开发之路,我在大厂做测试这四年的感悟
基础协议讲解
np.nan, np.isnan, None, pd.isnull, pd.isna finishing and summary
Thymeleaf
NVIDIA NeMo Metrics 轻量性能采集系统
openGauss数据库基本操作(超详细)
Name conventions in FreeRTOS
手撸架构,Redis面试41问
MyCat2 introduction and installation and basic use