当前位置:网站首页>mysql 函数
mysql 函数
2022-06-23 05:38:00 【小代码2016】
字符函数
大小写转换
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
对 str进行左边填补直至它的长度达到 len个字符长度,然后返回 str。如果 str的长度长于 len’,那么它将被截除到 len个字符。
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>
边栏推荐
- minio单节点部署 minio分布式部署 傻瓜式部署过程 (一)
- XShell7 下载
- Wechat applet - Global Monitoring of certain attribute changes of GlobalData, such as monitoring of network state switching
- 把CSMA/CD、Token Bus、Token Ring说清楚
- 快速认识 WebAssembly
- JSON to proto
- Haas506 2.0 development tutorial -hota (only supports versions above 2.2)
- 数值计算方法 Chapter7. 计算矩阵的特征值和特征向量
- 20220620 uniformly completely observable (UCO)
- Add IPAD control function into shairplay
猜你喜欢

Easy EDA learning notes 09 esp32-wroom-32e module esp32-devkitc-v4 development board one click download circuit

Sklearn classification in sklearn_ Report & accuracy / recall /f1 value

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

Summary of qvariant use in QT

解读创客教育中的团结协作精神

Open source ecology 𞓜 super practical open source license basic knowledge literacy post (Part 2)

【接口自动化】软件测试涨薪核心技能、让薪资涨幅200%

业务逻辑安全思路总结

How to maintain secure encryption of email communication with FDA?

如何实现与FDA保持邮件通信安全加密?
随机推荐
Usage Summary of item views and item widgets controls in QT
C语言学习总结
华为软件测试笔试真题之变态逻辑推理题
Skilled use of slicing operations
【shell】Tree命令
XShell7 下载
业务逻辑安全思路总结
问题:访问组件中数据object(定义的数据)中属性也为object对象中的属性时,报错现象
Link of Baidu URL Parameters? Recherche sur le chiffrement et le décryptage des paramètres d'URL (exemple de Code)
Steam教育对国内大学生的影响力
Measurement principle and thickness measurement mode of spectral confocal
快速认识 WebAssembly
XXL-SSO 实现SSO单点登录
js创建数组(元素都是对象)
如何查看本机IP
Phpstudy set 301 redirection
Kubesphere offline deployment without network environment
了解学习 JSX 的工作方式
Haas506 2.0 development tutorial - Advanced Component Library -modem Voicecall (only supports versions above 2.2)
C language obtains second, millisecond, subtle and nanosecond timestamps