MySQL database 8 - detailed explanation of the application of functions in the database

MySQL database 8 - detailed explanation of the application of functions in the database

Use of built-in functions in the database

This article mainly introduces the use of built-in functions in the database, mainly date functions, string functions, and mathematical functions.

1. Date functions

select current_date();//Get the current date, year, month, and dayselect current_time();//Get the current time, hours, minutes, and secondsselect current_timestamp();//Get the current year, month, day, hours, minutes, and secondsselect date('2017-10-28');//Get the parameter dateselect date_add('2017-10-28', interval 10 day);//Add the specified year/month/day to the parameter dateselect date_sub('2017-10-28', interval 10 day);//Subtract the specified year/month/day from the parameter dateselect datediff('2017-10-10', '2016-9-1');//Calculate the number of days between two dates

(II) String functions

(III) Mathematical functions

Other functions

  1. user() Query the current user
  2. md5(str) performs md5 digest on a string and obtains a 32-bit string after digest
  3. database() displays the database currently in use
  4. password() function, which is used by MySQL database to encrypt user
  5. ifnull(val1, val2) If val1 is null, returns val2, otherwise returns the value of val1
 //user() queries the current userselect user();
 
 //md5(str) performs md5 digest on a string and obtains a 32-bit string after digest select md5('admin')
 
 //database() displays the database currently in use select database();

 //password() function, MySQL database uses this function to encrypt users select password('root');
 
 //ifnull(val1, val2) If val1 is null, return val2, otherwise return the value of val1 select ifnull('abc', '123'); // abc is not null, so return abc

The above is what I introduced to you: MySQL Database 8 - Detailed explanation and integration of the application of functions in the database. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • How to implement scheduled backup of MySQL database
  • A brief analysis of using JDBC to operate MySQL requires adding Class.forName("com.mysql.jdbc.Driver")
  • Import backup between mysql database and oracle database
  • The simplest online question bank (online question system) developed by php+mysql
  • Detailed explanation of how a SQL statement is executed in MySQL
  • Detailed explanation of mysql download and installation process
  • Summary of MySQL LOAD_FILE() function method
  • MySQL 8.0.15 download and installation detailed tutorial is a must for novices!
  • Viewing and analyzing MySQL execution status
  • The use of mysql unique key in query and related issues

<<:  How to resize partitions in CentOS7

>>:  Detailed explanation of vue simple notepad development

Recommend

jQuery implements form validation

Use jQuery to implement form validation, for your...

Right align multiple elements in the same row under div in css

Method 1: float:right In addition, floating will ...

Issues with using Azure Container Registry to store images

Azure Container Registry is a managed, dedicated ...

mysql-8.0.17-winx64 deployment method

1. Download mysql-8.0.17-winx64 from the official...

Analyze how a SQL query statement is executed in MySQL

Table of contents 1. Overview of MySQL Logical Ar...

How to use Dockerfile to build images in Docker

Build the image Earlier we used various images fo...

MySQL master-slave replication principle and points to note

Written in front I have been writing a special to...

Detailed explanation of several methods of deduplication in Javascript array

Table of contents Array deduplication 1 Double-la...

Detailed explanation of sql_mode mode example in MySQL

This article describes the sql_mode mode in MySQL...

How to insert pictures into HTML pages and add map index examples

1. Image formats supported on the WEB: GIF: can s...

Mysql implements null value first/last method example

Preface We already know that MySQL uses the SQL S...