当前位置:网站首页>sql concat() function
sql concat() function
2022-07-30 06:46:00 【asdfadafd】
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
边栏推荐
- Blind injection, error injection, wide byte injection, stack injection study notes
- [MATLAB] Image Processing - Recognition of Traffic Signs
- Using custom annotations, statistical method execution time
- 五月份比赛WP
- FastAPI Quick Start
- POI工具类
- CTF之misc-日志分析
- Calendar类的习题
- Using PyQt5 to add an interface to YoloV5 (1)
- Powerhouse Cup Preliminary WP
猜你喜欢
运维工程师面试经历
DVWA installation tutorial (understand what you don't understand · in detail)
[HCTF 2018]admin
sqli-labs shooting range SQL injection learning Less-1
FastAPI 快速入门
Using PyQt5 to add an interface to YoloV5 (1)
Jackson 序列化失败问题-oracle数据返回类型找不到对应的Serializer
Competition WP in May
[HCTF 2018]admin
JVM学习(二) 垃圾收集器
随机推荐
SQL Server 数据库之生成与执行 SQL 脚本
Flink CDC implements Postgres to MySQL streaming processing transmission case
Calendar类的习题
Monstache执行monstache -f config.toml出错No processor type exists with name [attachment] [type=parse_exc
Nacos配置中心用法详细介绍
[Mozhe Academy] Identity Authentication Failure Vulnerability Actual Combat
[Mini Program Project Development--Jingdong Mall] Classification Navigation Area of uni-app
C#下大批量一键空投实现
MySQL数据库之JDBC编程
sql中 exists的用法
MySQL存储引擎
【Spark】Spark 高频面试题英语版(1)
Jackson 序列化失败问题-oracle数据返回类型找不到对应的Serializer
JDBC programming of MySQL database
Mycat2.0搭建教程
【数仓】数据质量
Deserialization character escape
在不同的服务器上基于docker部署redis主从同步
冒泡排序、选择排序、插入排序、快速排序
SSTI靶场