当前位置:网站首页>Mysql concat_ws、concat函数使用
Mysql concat_ws、concat函数使用
2022-06-12 22:19:00 【贝塔-突突】
一、概念
concat
功能介绍: 将多个字符串进行拼接。
语法: concat(字段,字段,字段,…)
concat实践
select CONCAT(id,',',age,',',name) AS line_info from user

如果连接串中存在NULL,则返回结果为NULL(我没遇到过):
select CONCAT(id,',',age,',',null) AS line_info from user

Null解决方案:
加一个 IFNULL()函数。
select CONCAT(id,',',age,',',IFNULL(name,'')) AS line_info from user

concat_ws
功能介绍: 字符串拼接无需手动添加分隔符(自己理解)。
语法:concat_ws(分隔符,字段,字段,…)
concat_ws实践
select CONCAT_WS(',',id,age,name) AS line_info from user

二、混合使用函数实战
select CONCAT_WS(',',concat(name),concat('年龄',age,'岁')) AS line_info from user

边栏推荐
- 六月集训(第12天) —— 链表
- JVM foundation - > three ⾊ mark
- 孙老师版本JDBC(2022年6月12日21:34:25)
- Is it safe to open an account with new bonds? How should novices operate?
- Is it safe to open an account in tonghuashun? How to open an account
- PE installation win10 system
- SQL tuning guide notes 10:optimizer statistics concepts
- Have you really learned the common ancestor problem recently?
- C # reading table data in word
- List of open source alternative projects of world famous Cloud Service SaaS companies
猜你喜欢

JVM Basics - > how to troubleshoot JVM problems in your project

How to perform disaster recovery and recovery for kubernetes cluster? (22)

Ansible playbook和Ansible Roles(三)

SQL tuning guide notes 17:importing and exporting optimizer statistics

SQL tuning guide notes 16:managing historical optimizer statistics

Xingda easy control ModbusRTU to modbustcp gateway

Ansible playbook and variable (II)

leetcodeSQL:574. Elected

Preliminary use of jvisualvm

IPhone: save Boolean into core data - iphone: save Boolean into core data
随机推荐
MySQL architecture and basic management (II)
[simple] 155 Minimum stack
Vagrantbox reinstalling the vboxsf driver
六月集训(第12天) —— 链表
USB机械键盘改蓝牙键盘
Prefix sum and difference
Palindrome linked list and linked list intersection problem (intersecting with Xinyi people) do you really know?
How do I create a daemon thread? And where to use it?
IPhone: save Boolean into core data - iphone: save Boolean into core data
大学期间零基础如何开展编程学习
Wechat applet withdrawal function
Mr. Sun's version of JDBC (21:34:25, June 12, 2022)
【LeetCode】103. 二叉树的锯齿形层序遍历
【LeetCode】数组中第K大的元素
Interpretation of OCP function of oceanbase Community Edition
The 2023 campus recruitment officially opened! Oceanbase would like to make an interview with you this spring
设计消息队列存储消息数据的 MySQL 表格
回文链表及链表相交问题(和心怡的人相交)你真的会了吗?
SQL tuning guide notes 13:gathering optimizer statistics
JVM Basics - > What are the thread shared areas in the JVM