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

The difference between ${param} and #{param} in MySQL

The parameter passed by ${param} will be treated ...

Solution to inserting a form with a blank line above and below

I don't know if you have noticed when making a...

Linux centOS installation JDK and Tomcat tutorial

First download JDK. Here we use jdk-8u181-linux-x...

vue uses Ele.me UI to imitate the filtering function of teambition

Table of contents Problem Description The general...

Tutorial on installing and uninstalling python3 under Centos7

1. Install Python 3 1. Install dependency package...

HTML end tag issue and w3c standard

According to the principles of W3C, each start tag...

js implements custom drop-down box

This article example shares the specific code of ...

Analysis of the principles of Mysql dirty page flush and shrinking table space

mysql dirty pages Due to the WAL mechanism, when ...

Summary of MySQL injection bypass filtering techniques

First, let’s look at the GIF operation: Case 1: S...

Vue3.x uses mitt.js for component communication

Table of contents Quick Start How to use Core Pri...

MySQL transaction analysis

Transaction A transaction is a basic unit of busi...

Is mysql a relational database?

MySQL is a relational database management system....

Detailed examples of replace and replace into in MySQL into_Mysql

MySQL replace and replace into are both frequentl...