当前位置:网站首页>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))
边栏推荐
猜你喜欢
[jetbrain rider] an exception occurred in the construction project: the imported project "d:\visualstudio2017\ide\msbuild\15.0\bin\roslyn\microsoft.csh" was not found
Operator-1 first acquaintance with operator
"Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
12. Process synchronization and semaphore
13.信号量临界区保护
Win11 arm系统配置.net core环境变量
Session cookies and tokens
Solutions to a series of problems in sqoop job creation
14. Code implementation of semaphore
Pytest framework implements pre post
随机推荐
"Matching" is true love, a new attitude for young people to make friends
《MySQL 8 DBA基础教程》简介
Ks009 implement pet management system based on SSH
KS009基于SSH实现宠物管理系统
13.信号量临界区保护
UVM learning - build a simple UVM verification platform
Pytest learning --base
VSCode工具使用
01-spooldir
VLAN experiment
SQOOP 1.4.6 INSTALL
(五)APA场景搭建之挡位控制设置
1287_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
What is the significance of the college entrance examination
2021-10-04
Allure -- common configuration items
[SUCTF2018]followme
Nonlinear optimization: establishment of slam model
两数之和,求目标值
AI技术产业热点分析