MySQL detailed summary of commonly used functions

MySQL detailed summary of commonly used functions

MySQL Common Functions

1. Numeric Functions

insert image description here

Additional: ceil(x) For example, if ceil(1.23) has a value of 2, it can be written as ceiling(x)

String functions

insert image description here

The dash is commonly used (to get the number of bytes)

insert image description here

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

insert image description here

Usage: select now();

4. System Function

insert image description here

To 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 Functions

Aggregate multiple data to calculate a single data value

insert image description here

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');

Please add a description of the image

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:
  • Thoroughly understand MySQL stored procedures and functions
  • Analysis of the difference between MySQL stored functions and stored procedures
  • Introduction to commonly used functions in MYSQL database
  • MySQL batch inserts data through function stored procedures
  • MySQL stored functions detailed introduction
  • Detailed explanation of creating stored procedures and functions in mysql
  • Comprehensive summary of mysql functions
  • How to use MYSQL functions

<<:  Use ab tool to perform API stress test on the server

>>:  Example of converting JS one-dimensional array into three-dimensional array

Recommend

Analysis of the difference between absolute path and relative path in HTML

As shown in the figure: There are many files conne...

Detailed explanation of the use of this.$set in Vue

Table of contents Use of this.$set in Vue use Why...

Two ways to build Docker images

Table of contents Update the image from an existi...

Solution to Linux CentOS 6.5 ifconfig cannot query IP

Recently, some friends said that after installing...

4 Ways to Quickly Teach Yourself Linux Commands

If you want to become a Linux master, then master...

Detailed explanation of Vue router routing

Table of contents 1. Basic use 2. Several points ...

Node.js sends emails based on STMP protocol and EWS protocol

Table of contents 1 Node.js method of sending ema...

Detailed explanation of MySQL cursor concepts and usage

This article uses examples to explain the concept...

Summary of commonly used commands for docker competition submission

Log in to your account export DOCKER_REGISTRY=reg...

4 ways to optimize MySQL queries for millions of data

Table of contents 1. The reason why the limit is ...

mysql three tables connected to create a view

Three tables are connected. Field a of table A co...

Talk about important subdirectory issues in Linux system

/etc/fstab Automatically mount partitions/disks, ...

jQuery realizes the shuttle box function

This article example shares the specific code of ...