MySQL Learning 19: Information functions of operators and functions, aggregate functions, cryptographic functions

Source: Internet
Author: User

information Functions

The commonly used information functions are:


(1) View database connection ID and current database

SELECT connection_id ();

SELECT DATABASE ();


(2) Check the ID number of the last input record

ALTER TABLE Test ADD ID SMALLINT UNSIGNED keyauto_increment first;

INSERT Test (First_name,last_name) VALUES (' 11 ', ' 22 ');

SELECT last_insert_id ();

SELECT * from Test;


(3) View current user and version information (already used)

SELECT USER ();

SELECT VERSION ();


aggregation Functions

Common aggregation functions:


One common denominator of aggregate functions is that there is only one return value.

(1) averaging using AVG () function

Use T2;

SHOW TABLES;

SELECT ROUND (AVG (Goods_price), 2) as Avg_price from Tdb_goods;


(2) using the Count function, the maximum function, and the minimum value function

SELECT COUNT (goods_id) as counts from Tdb_goods;

SELECT MAX (goods_price) as Max_price from Tdb_goods;

SELECT MIN (Goods_price) as Min_price from Tdb_goods;


(3) sum with sum () function

SELECT SUM (goods_price) as Sum_price from Tdb_goods;


Cryptographic Functions

Common cryptographic functions:


examples of using cryptographic functions

SELECT MD5 (' admin ');

SELECT PASSWORD (' admin ');


Recommendations for using cryptographic functions:

If it is for future web pages to prepare, then we try to use MD5 (); PASSWORD () There is only one use, that is, we are repairing the client

You can use it when you have a password.

To modify the format of a client password:

SET password=password (' 123123 ');


MySQL Learning 19: Information functions of operators and functions, aggregate functions, cryptographic functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.