MySQL's advanced additions and deletions to a

Source: Internet
Author: User

One, select all/distinct field name/alias from table where Condition + "1" + "2" + "3";

Where Condition: >,<,≥,≤,like,between and (closed interval), in, No in, with &&, or | |, non!

All: Query go all

Distinct: Remove Duplicate results

"1": Group BY "ASC/DESC" ASC: Ascending, desc: Descending

"2": ORDER BY

"3": Limit limit 3: Take the first 3 records; limit 2, 3: Starting from the third record, Fetch 3 records (starting from position 2, length 3)

1, example demonstration

First build a table, ID primary key (primary key), and self-growth (auto_increment)

CREATE TABLE TESTABC (ID int primary KEY auto_increment,name varchar (4));

Add data

INSERT into TESTABC set name= ' a ';

Bulk Add

Insert into TESTABC (name) VALUES (' a '), (' B '), (' C '), (' C '), (' A '), (' a ');

SELECT * from TESTABC where name= ' a ';

SELECT * FROM TESTABC group by name;

Limit the top 3 select * from TESTABC limit 3;

SELECT * from TESTABC limit 2, 3; Starting from the third record, Fetch 3 records (starting from position 2, length is 3)

Second, common function Max (), Min (), AVG (), COUNT (), COUNT ()---record value is null when no count in

1, examples of demonstration, the table is as follows

Select Max (age) from Stu;

Select Sex, COUNT (*) from Stu Group by sex;

Select Sex,count (*), Max (age), AVG (age) from Stu Group by sex;

MySQL's advanced additions and deletions to a

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.