当前位置:网站首页>MySQL function
MySQL function
2022-06-23 06:50:00 【Small code 2016】
Character functions
toggle case
mysql> select employee_id,upper(concat(first_name,' ',last_name)) as full_name from employees limit 0,10;
+-------------+------------------+
| employee_id | full_name |
+-------------+------------------+
| 100 | STEVEN K_ING |
| 101 | NEENA KOCHHAR |
| 102 | LEX DE HAAN |
| 103 | ALEXANDER HUNOLD |
| 104 | BRUCE ERNST |
| 105 | DAVID AUSTIN |
| 106 | VALLI PATABALLA |
| 107 | DIANA LORENTZ |
| 108 | NANCY GREENBERG |
| 109 | DANIEL FAVIET |
+-------------+------------------+
10 rows in set (0.06 sec)
mysql> select employee_id,lower(concat(first_name,' ',last_name)) as full_name from employees limit 0,10;
+-------------+------------------+
| employee_id | full_name |
+-------------+------------------+
| 100 | steven k_ing |
| 101 | neena kochhar |
| 102 | lex de haan |
| 103 | alexander hunold |
| 104 | bruce ernst |
| 105 | david austin |
| 106 | valli pataballa |
| 107 | diana lorentz |
| 108 | nancy greenberg |
| 109 | daniel faviet |
+-------------+------------------+
10 rows in set (0.06 sec)
mysql>
concat
···sql
select employee_id,concat(first_name,’ ',last_name) as full_name from employees limit 0,10;
···
mysql> select employee_id,first_name,last_name from employees limit 0,10;
+-------------+------------+-----------+
| employee_id | first_name | last_name |
+-------------+------------+-----------+
| 100 | Steven | K_ing |
| 101 | Neena | Kochhar |
| 102 | Lex | De Haan |
| 103 | Alexander | Hunold |
| 104 | Bruce | Ernst |
| 105 | David | Austin |
| 106 | Valli | Pataballa |
| 107 | Diana | Lorentz |
| 108 | Nancy | Greenberg |
| 109 | Daniel | Faviet |
+-------------+------------+-----------+
10 rows in set (0.07 sec)
mysql> select employee_id,concat(first_name,' ',last_name) as full_name from employees limit 0,10;
+-------------+------------------+
| employee_id | full_name |
+-------------+------------------+
| 100 | Steven K_ing |
| 101 | Neena Kochhar |
| 102 | Lex De Haan |
| 103 | Alexander Hunold |
| 104 | Bruce Ernst |
| 105 | David Austin |
| 106 | Valli Pataballa |
| 107 | Diana Lorentz |
| 108 | Nancy Greenberg |
| 109 | Daniel Faviet |
+-------------+------------------+
10 rows in set (0.07 sec)
mysql>
length
mysql> select employee_id,length(concat(first_name,' ',last_name)) as full_name from employees limit 0,10;
+-------------+-----------+
| employee_id | full_name |
+-------------+-----------+
| 100 | 12 |
| 101 | 13 |
| 102 | 11 |
| 103 | 16 |
| 104 | 11 |
| 105 | 12 |
| 106 | 15 |
| 107 | 13 |
| 108 | 15 |
| 109 | 13 |
+-------------+-----------+
10 rows in set (0.06 sec)
mysql>
substr
mysql> select employee_id,substr(concat(first_name,' ',last_name),1,5) as full_name from employees limit 0,10;
+-------------+-----------+
| employee_id | full_name |
+-------------+-----------+
| 100 | Steve |
| 101 | Neena |
| 102 | Lex D |
| 103 | Alexa |
| 104 | Bruce |
| 105 | David |
| 106 | Valli |
| 107 | Diana |
| 108 | Nancy |
| 109 | Danie |
+-------------+-----------+
10 rows in set (0.06 sec)
mysql>
instr
mysql> select employee_id,instr(concat(first_name,' ',last_name),'x') as full_name from employees limit 0,10;
+-------------+-----------+
| employee_id | full_name |
+-------------+-----------+
| 100 | 0 |
| 101 | 0 |
| 102 | 3 |
| 103 | 4 |
| 104 | 0 |
| 105 | 0 |
| 106 | 0 |
| 107 | 0 |
| 108 | 0 |
| 109 | 0 |
+-------------+-----------+
10 rows in set (0.05 sec)
mysql>
lpad
Yes str Fill the left until its length reaches len Character length , Then return str. If str The length of is longer than len’, Then it will be truncated to len Characters .
mysql> select employee_id,lpad(phone_number,20,'*') from employees limit 0,10;
+-------------+---------------------------+
| employee_id | lpad(phone_number,20,'*') |
+-------------+---------------------------+
| 100 | ********515.123.4567 |
| 101 | ********515.123.4568 |
| 102 | ********515.123.4569 |
| 103 | ********590.423.4567 |
| 104 | ********590.423.4568 |
| 105 | ********590.423.4569 |
| 106 | ********590.423.4560 |
| 107 | ********590.423.5567 |
| 108 | ********515.124.4569 |
| 109 | ********515.124.4169 |
+-------------+---------------------------+
10 rows in set (0.06 sec)
mysql>
边栏推荐
猜你喜欢

【系统】右键桌面图标,转圈后,资源管理器就崩溃,桌面就重新刷新

How to realize video call and live interaction in a small program when live broadcasting is so popular?

剑指 Offer 42. 连续子数组的最大和

数据在内存中的存储方式(C语言)

idea自动生成serialVersionUID

C# wpf 附加属性实现界面上定义装饰器

Business logic design of physical warehouse and virtual warehouse in middle inventory

Haas506 2.0 development tutorial - Advanced Component Library -modem SMS (only supports versions above 2.2)

Network architecture from Wan to sd-wan edge devices

mingw-w64、msys和ffmpeg的配置与编译
随机推荐
Haas506 2.0 development tutorial - Advanced Component Library -modem SMS (only supports versions above 2.2)
项目_过滤器Filter解决中文乱码
MySQL ON DUPLICATE KEY 和 PgSQL ON CONFLICT(主键) 处理主键冲突
Programmers' real ideas | daily anecdotes
Network architecture from Wan to sd-wan edge devices
C语言运算符优先级口诀
Wechat applet - Global Monitoring of certain attribute changes of GlobalData, such as monitoring of network state switching
mars3d点线面的绘制和重置
Give up Visio, this drawing tool is really fragrant!
Termux
2022年养老理财产品有哪些?风险小的
haas506 2.0开发教程-高级组件库-modem.net(仅支持2.2以上版本)
Cloud box is deeply convinced to create a smart dual-mode teaching resource sharing platform for Nanjing No. 1 middle school
994. 腐烂的橘子-非递归法
解析创客教育中的个性化学习进度
SAP execution transaction code mrrl error -no message was found for partner 100065-
Get to know webassembly quickly
疫情下的传媒产业,小程序生态驱动数字化转型探索
leetcode - 572. 另一棵树的子树
页面嵌入iframe 点击浏览器后退问题