当前位置:网站首页>Zero foundation self-study SQL course | complete collection of SQL basic functions
Zero foundation self-study SQL course | complete collection of SQL basic functions
2022-06-27 23:41:00 【Meow Ningyi】
Hello everyone , I'm Ning Yi .
Today is our first 20 course :SQL Basic functions .
MySQL There are many functions built in , Used to process values 、 character string 、 Date, etc. , In this lesson, let's talk about some common functions .
1、 Numerical function
-- ROUND( The number , Keep decimals ) rounding
SELECT ROUND(3.456, 2); -- 3.46
-- TRUNCATE( The number , Keep decimals ) truncation
SELECT TRUNCATE(3.456, 2); -- 3.45
-- CEILING( The number ) The smallest integer greater than or equal to this number
SELECT CEILING(3.456); -- 4
-- FLOOR( The number ) The largest integer less than or equal to this number
SELECT FLOOR(3.456); -- 3
-- ABS( The number ) The absolute value
SELECT ABS(-3.456); -- 3.456
-- RAND() Random function ,0 To 1 The random value
SELECT RAND(); -- 0.92064982738406392、 String function
-- LENGTH( character string ) String length
SELECT LENGTH('Cat'); -- 3
-- UPPER( character string ) Turn capitalization
SELECT UPPER('Cat'); -- 'CAT'
-- LOWER( character string ) Turn lowercase
SELECT LOWER('Cat'); -- 'cat'
-- TRIM( character string ) Remove the space on both sides
SELECT TRIM(' Cat '); -- 'Cat'
-- LTRIM( character string ) Take out the space on the left
SELECT LTRIM(' Cat '); -- 'Cat '
-- RTRIM( character string ) Remove the space on the right
SELECT RTRIM(' Cat '); -- ' Cat'
-- LEFT( character string , Character length n) Take... From the left n Characters
SELECT LEFT('CatNing', 4); -- 'CatN'
-- RIGHT( character string , Character length n) Take... From the right n Characters
SELECT RIGHT('CatNing', 4); -- 'Ning'
-- SUBSTRING( character string , Starting position s, Character length n) From s Start counting with characters , take n Characters
-- Here we should pay attention to the separation from other programming languages , Other programming language indexes are mostly from 0 Start , And in the SQL From 1 Start
SELECT SUBSTRING('CatNing', 3, 4); -- 'tNin'
-- LOCATE( character a, character b) Positioning characters a In the character b The first place in , If not, return to 0
-- Case insensitive
SELECT LOCATE('ning', 'CatNing'); -- 4
-- REPLACE( character a, character b, character c) In the character a in , Use string c Replace string b
-- Case sensitive
SELECT REPLACE('CatNing', 'Cat', 'Mao'); -- 'MaoNing'
-- CONCAT( character a, character b) The character a、 character b Splice up
SELECT CONCAT('Cat', 'Ning'); -- 'CatNing'Homework : take Students In the table , The student's name Sname And Student gender Ssex Splice up , Space in the middle , And add a list of random numbers .
Sample results :

SELECT
CONCAT(Sname,' ',Ssex) AS " full name Gender ",
RAND() AS ' random number '
FROM Students;Next class we'll talk about MySQL Date function .
Click on Focus on , Update the course and notify the first time ~
边栏推荐
- 打造南沙“强芯”,南沙首届IC Nansha大会召开
- 【PCL自学:Segmentation4】基于Min-Cut点云分割
- C# Winform 读取Resources图片
- CUDA error:out of memory caused by insufficient video memory of 6G graphics card
- matlab axis坐标轴相关设置详解
- The choice and trade-off between vector recall and literal recall
- 如何找到外文文献对应的中文文献?
- const关键字及其作用(用法),C语言const详解
- halcon之区域:多种区域(Region)特征(6)
- MySQL删除表后如何使ID从1开始
猜你喜欢
![[tinyriscv verilator] branch transplanted to Da Vinci development board of punctual atom](/img/a8/4786e82d0646b08c195dd0a17af227.png)
[tinyriscv verilator] branch transplanted to Da Vinci development board of punctual atom

实践torch.fx:基于Pytorch的模型优化量化神器

如何设置企业微信群机器人定时发消息?

Structure de stockage des graphiques

vivado 如何添加时序约束

Teach you how to transplant tinyriscv to FPGA

Windows环境下的ELK——Logstash+Mysql(4)

Swing UI container (I)

ASP.NET仓库进销存ERP管理系统源码 ERP小程序源码

c语言之字符串数组
随机推荐
使用cef3开发的浏览器不支持flash问题的解决
Discuz taobaoke website template / Dean taobaoke shopping style commercial version template
VMware virtual machine bridging connectivity
打造南沙“强芯”,南沙首届IC Nansha大会召开
圖的存儲結構
【PCL自学:PCLVisualizer】点云可视化工具PCLVisualizer
Feign implements path escape through custom annotations
【Vim】使用教程,常用命令,高效使用Vim编辑器
C WinForm reads the resources picture
Const keyword and its function (usage), detailed explanation of C language const
电子科大(申恒涛团队)&京东AI(梅涛团队)提出用于视频问答的结构化双流注意网络,性能SOTA!优于基于双视频表示的方法!
消除el-image图片周围间隙
ICML 2022: UFRGS |作为最优策略转移基础的乐观线性支持和后继特征
十大券商注册账户安全吗,会有风险吗?
go日志包 log的使用
How to use the apipost script - global variables
vivado VIO IP的用法
捷码赋能案例:湖南天辰产研实力迅速提升!实战玩转智慧楼宇/工地等项目
[try to hack] kill evaluation
上手了一个自然语言模型BLOOM