当前位置:网站首页>MySQL keyword
MySQL keyword
2022-07-02 10:48:00 【Zhang Yi's blog】
1.TIMESTAMPDIFF
- effect
* Calculate the integer difference between function dates or date expressions
TIMESTAMPDIFF(PARAM,DATETIME1,DATETIME2)
#DATETIME1, and DATETIME2 Time difference between , With param In units of time
# The supported time units are :
#FRAC_SECOND Interval milliseconds ,*SECOND second ,*MINUTE minute ,*HOUR Hours ,*DAY God ,*WEEK week ,*MONTH month ,#*QUARTER quarter ,*YEAR year
2.AVG
- effect
* averaging , You can find the average value of a certain field , You can also find the average of all the values of a function formula
AVG( Field )
AVG( Value of formula )
3.IF(trueOrfalse,param2,param3)
effect
* Make a judgment on the condition , If the judgment is true , If the expression is true The return value is param2, If the expression is false The return value is param3
IF( expression , The return value when the expression is true , The return value when the expression is false )
4.substring_index(str,delim,count)
- effect
* Cut string
substring_index(str,delim,count)
#str Cutting objects String object to intercept
#delim Separator With what mark to cut the target object
#num Serial number Used to control cutting objects , When positive ( barring 0) Cut from left to right , When it is negative, from right to left
5.CAST( target AS CHAR)
effect
* Convert the results of the query into char type
CAST( expression AS CHAR)
6.CONCAT(char c1, char c2, …, char cn)
- effect
* String splicing
CONCAT(char c1, char c2, …, char cn)
7.DATE_SUB(date,INTERVAL expr type)
- effect
* Function to subtract a specified time interval from a date
DATE_SUB(date,INTERVAL expr type)
#date: Legal date expression
#expr: Number
#type: type --》MICROSECOND SECOND MINUTE HOUR DAY WEEK MONTH QUARTER YEAR SECOND_MICROSECOND MINUTE_MICROSECOND MINUTE_SECOND HOUR_MICROSECOND HOUR_SECOND HOUR_MINUTE DAY_MICROSECOND DAY_SECOND DAY_MINUTE DAY_HOUR YEAR_MONTH
8. obtain datatime Type year month day
1. Directly through year(),month(),day()
select year(dattime Type field ),month(dattime Type field ),day(dattime Type field ) from ' Table name '2. Use datepart Keyword get date
datepart('year',' Field name '),datepart('month',' Field name '),datepart('day',' Field name ')
9.mysql Keep decimals in
1. Use round(x,d) -->x For the object to keep ,d Is the decimal to keep
Be careful : Keep decimals in this way , Don't add when the number of digits is not enough 0, The final retention result will be rounded ,d It could be negative , Take the decimal point as 0 The dividing line of , Below the corresponding digits on the left becomes 0
2.turncate(x,d) and round similar , It's just not rounded
3.**format(x,d)** Force to keep the corresponding decimal places. If the decimal is not enough, fill in zero , The return value is string type
4.**convert(num,type)** Equivalent to interception
CONVERT(100.3465,DECIMAL(10,2))
边栏推荐
- Transport Optimization abstraction
- Operator-1 first acquaintance with operator
- MySQL数据库远程访问权限设置
- Redis set password
- Pytest framework implements pre post
- UVM learning - build a simple UVM verification platform
- 02-taildir source
- Understand the composition of building energy-saving system
- [Fantasy 4] the transformation from U3D to UE4
- 高考的意义是什么
猜你喜欢

MYSQL环境配置

数据库字典Navicat自动生成版本

Flink calculates topn hot list in real time
![[unity3d] nested use layout group to make scroll view with dynamic sub object height](/img/b2/edab4ab48e1401934dcce7218df662.png)
[unity3d] nested use layout group to make scroll view with dynamic sub object height

LeetCode+ 76 - 80 暴搜专题

拆解美图SaaS:开着飞机换引擎

Mysql database remote access permission settings

(五)APA场景搭建之挡位控制设置

对话吴纲:我为什么笃信“大国品牌”的崛起?

使用sqlcipher打开加密的sqlite方法
随机推荐
The nanny level tutorial of flutter environment configuration makes the doctor green to the end
2021-10-02
SPSS做Shapiro-Wilk正态分析
面对不确定性,供应链的作用
数据库字典Navicat自动生成版本
Flutter环境配置保姆级教程,让doctor一绿到底
AttributeError: type object ‘Image‘ has no attribute ‘fromarray‘
Operator-1 first acquaintance with operator
PCL 从一个点云中提取一个子集
Stm32 et développement de moteurs (système supérieur)
网络通信学习
01 install virtual machine
MYSQL关键字
js数组常用方法
拆解美图SaaS:开着飞机换引擎
[unity3d] nested use layout group to make scroll view with dynamic sub object height
2.hacking-lab脚本关[详细writeup]
PCL之K-d树与八叉树
"Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
[Fantasy 4] the transformation from U3D to UE4