MySQL Common Functions1. Numeric FunctionsAdditional: ceil(x) For example, if ceil(1.23) has a value of 2, it can be written as ceiling(x) String functionsThe dash is commonly used (to get the number of bytes) Add: char_length character (query the last three digits of the name) For example: char_length(name)=3 can be written as: select left(name,1) from c1; 3. Time function
4. System FunctionTo add a separator: select concat_ws('#',name,tel,height) from xxb; select (substr(Now(),1,4)-substr(age,1,4) as agefrom zxc; Explanation of the following SQL statements: The first now() is used for comparison, interval 50 minute means pushing back 50 units, and -50 means pushing forward 50 units. year(now()) gets the year; month(now()) gets the month; day(now()) gets the day; nour(now()) gets the hour; minute(now()) gets the minute; second(now()) gets the second select now(),date_add(now(),interval 50 minute); Get the day of the week: select dayofweek(now()),dayname(now()); 5. Aggregation FunctionsAggregate multiple data to calculate a single data value usage: select sum(height) from c1; Get the number of records (number of rows), and filter out empty values: count() If there is one empty row in 14 rows, count() will be 13 rows. Count() can be accompanied by count(*) for more accuracy. Count(*) is generally used for statistics. Calculate the difference between two dates in multiple units, such as: select timestampdiff (time unit, date time 1, date time 2) written as: select timestampdiff(day,'2021-11-18','2021-11-22'); Thank you to everyone who read my article carefully! ! ! If the following materials are useful, you can take them directly: 1. Complete project source code and environment required for self-study development or testing 2. All templates in testing work (test plan, test case, test report, etc.) 3. Classic software testing interview questions 4. Python/Java Automation Testing Practice.pdf 5. Jmeter/postman interface test full set of video acquisition This is the end of this article on MySQL's detailed summary of commonly used functions. For more relevant MySQL commonly used functions, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Use ab tool to perform API stress test on the server
>>: Example of converting JS one-dimensional array into three-dimensional array
Table of contents Master-Master Synchronization S...
Table of contents When declaring multiple variabl...
First look at the example code: #/bin/bash cal da...
The installation of MySQL 5.7 on Ubuntu 1804 is i...
I recently used the input size and maxlength attri...
Summary: In order to make your web page look more...
Preface: When passing data between parent and chi...
The following is an introduction to using SQL que...
After many difficult single-step debugging late a...
The format of textarea can be saved to the databas...
Table of contents Preface: 1. Introduction to Use...
1. Unzip the downloaded file as shown below . 2. ...
Quick Start 1. Find the nginx image on Docker Hub...
This article example shares the specific code of ...
Dynamically implement a simple secondary menu Whe...