当前位置:网站首页>sql concat()函数
sql concat()函数
2022-07-30 05:50:00 【饿饿好饿】
1.concat()
concat()函数用于将两个字符串连接起来,形成一个单一的字符串
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;
结果:
CONCAT(id, name, work_date)
1John2007-01-24
2Ram2007-05-27
2.concat_ws()
使用方法:concat_ws(separator ,str2,str2,…)
concat_ws()代表concat with separator,是concat()函数的特殊形式。
第一个参数是其他参数的分隔符,分隔符的位置要放在两个字符串连接的位置之间。分割符可以是一个字符串,也可以是其他参数
注意:如果分隔符为NULL,那么结果也为NULL,函数会忽略任何分隔符参数后的NULL值
eg:
select concat_ws(',','11','22','33');
结果:
concat_ws(‘,’,‘11’,‘22’,‘33’)
11,22,33
eg:
select concat_ws(',','11','22',NULL);
结果:
concat_ws(‘,’,‘11’,‘22’,NULL)
11,22
3.group_concat()
完整的语法如下:
group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator ‘分隔符’])
eg:
id
name
1
10
1
20
2
10
2
20
3
200
3
500
sql: 以id分组,把name字段的值打印在一行,分号分隔
select id,group_concat(name separator ';') from aa group by id;
结果:
id
name
1
10;20
2
10;20
3
200;500
边栏推荐
- bin文件夹下的roslyn文件夹
- iptables命令
- export , export default,import完整用法
- 向量的导数运算和向量叉乘以及点乘的导数运算
- MySQL主从复制配置搭建,一步到位
- idea内置翻译插件
- Linx常见目录&文件管理命令&VI编辑器使用 介绍
- The introduction of AI meta-learning into neuroscience, the medical effect is expected to improve accurately
- Electron之初出茅庐——搭建环境并运行第一个程序
- idea built-in translation plugin
猜你喜欢
Dachang's annual salary of 50w+ recruits test engineers with test platform development capabilities
Proof of distance calculation from space vertex to plane and its source code
不会吧,Log4j 漏洞还没有完全修复?
Redis 如何实现防止超卖和库存扣减操作?
分布式系统中的开创者—莱斯利·兰伯特
Test and Development Engineer Growth Diary 009 - Environment Pai Pai Station: Development Environment, Test Environment, Production Environment, UAT Environment, Simulation Environment
numpy 多维数组ndarray的详解
matlab机器学习_01
Multithreading basics (multithreaded memory, security, communication, thread pools and blocking queues)
Calculate the inverse source of the matrix (using the adjoint matrix, a 3x3 matrix)
随机推荐
The terminal connection tools, rolling Xshell
Electron日常学习笔记
Multithreading basics (multithreaded memory, security, communication, thread pools and blocking queues)
大飞机C919都用了哪些新材料?
你被MySQL 中的反斜杠 \\坑过吗?
搭建vsftpd服务并实现本地用户访问
DHCP原理与配置
深度学习:线性回归模型
识别“数据陷阱”,发现数据的可疑之处
Polygon 3D(三维平面多边形)的法向量的计算(MeshLab默认的计算)
debian vsftpd + ssl
软件测试术语 - 场景测试
MongoDB-CUD without R
Proof of distance calculation from space vertex to plane and its source code
MYSQL-GROUP BY 用法 全网最精,通熟易懂的话解释
Test development engineer diary 002 - starting from 0 interface automation
Electron中设置菜单(Menu),主进程向渲染进程共享数据
Equation Derivation Proof of Vector Triple Product
Selenium01
New breakthrough in artificial muscle smart materials