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