当前位置:网站首页>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))
边栏推荐
- 01-spooldir
- Shutter - canvas custom graph
- Test -- Summary of interview questions
- 2021-09-12
- Mysql database remote access permission settings
- "Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
- js数组常用方法
- Pywin32 opens the specified window
- Redis set password
- JS settimeout() and interview questions
猜你喜欢
随机推荐
12. Process synchronization and semaphore
What is the significance of the college entrance examination
Solutions to a series of problems in sqoop job creation
UVM——Callback
(5) Gear control setting of APA scene construction
Determine whether there are duplicate elements in the array
Flutter环境配置保姆级教程,让doctor一绿到底
In the face of uncertainty, the role of supply chain
Is this code PHP MySQL redundant?
Flink calculates topn hot list in real time
Sus system availability scale
PCL之滤波
Kustomize使用手册
Excuse me, is it cost-effective to insure love life patron saint 2.0 increased lifelong life insurance? What are the advantages of this product?
Operator-1初识Operator
MongoDB-快速上手MongoDB命令行的一些简单操作
MYSQL关键字
Internet News: Tencent conference application market was officially launched; Soul went to Hong Kong to submit the listing application
[pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces
判断数组中是否存在重复元素








![[Fantasy 4] the transformation from U3D to UE4](/img/bb/665eba3c8cd774c94fe14f169121da.png)
