当前位置:网站首页>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
边栏推荐
- php字符串的截取方式
- Solve the problem of Chinese garbled characters in exporting excel file names
- String concatenation in SQL
- Likou 704 - binary search
- How to set up wireless PPI communication between Weiluntong touch screen and S7-200smart?
- Process finished with exit code 1
- Good shooting js game source code
- Intouch Historian历史曲线配置导入导出
- PHP伪协议详解
- 分布式限流利器,手撕&redisson实现
猜你喜欢

Manual architecture, Mysql interview 126 questions

手撸架构,Mysql 面试126问

FreeRTOS experiment--one function creates multiple tasks

Leek 151 - Reverse words in a string

js真3d柱状图插件

Likou 977-Squaring of ordered arrays - brute force method & double pointer method

linux basic command explanation

LeetCode_139_word split

力扣977-有序数组的平方——暴力法&双指针法

DTG-SSOD: The latest semi-supervised detection framework, Dense Teacher (with paper download)
随机推荐
SQL Server如何建表
Data Lake (2): What is Hudi
FreeRTOS实验--一个函数创建多个任务
How to set up wireless PPI communication between Weiluntong touch screen and S7-200smart?
MyCat2的介绍与安装以及基本使用
Likou 209 - String with the Minimum Length - Sliding Window Method
30行代码实现无服务器实时健康码识别--操作手册
Lexicon 27 - Remove Elements - Simple Questions
如何搭建威纶通触摸屏与S7-200smart之间无线PPI通信?
30 lines of code to realize serverless real-time health code recognition -- operation manual
【第六届强网杯CTF-Wp】
【The 6th Strong Net Cup CTF-Wp】
FreeRTOS--优先级实验
ssm access database data error
svg实现的树木四季变化
MD5详解(校验文件完整性)
LeetCode_377_Combination Sum IV
机器人碰撞检测方法形式化
数据湖(三):Hudi概念术语
不错的射击类js小游戏源码