Select field 1, Field 2 from Table 1, table 2 where field group by Group Field having field order by field asc| DESC Limit M,n
First, to inquire all
Select * from student;
Select as from student;
Select from student;
Second, the conditions of inquiry
1. Query student ID equals 1
* from where student_id;
2. Query the Name field NULL
* from where is null;
3. Query the name field is not NULL
Select * from where is not null;
4. Query the Name field is an empty string
Select * from where = ";
5. Query the Name field is not an empty string and is not NULL
Select * from where != ";
6. Query the city character Gencun data in Henan province and Shandong Province
Select * from where inch (' Shandong province ',' Henan province ');
7. Query age from 25 to 30
Select * from where between - and ;
8. Query that age is not between 20 and 30
Select * from where not between - and ;
9. Query the first word is Guo's data
Select * from where like ' Guo% ';
10 Query The first word is Guo's two characters of data
Select * from where like ' Guo _ ';
11 Query the existence of Guo's Word data
Select * from where like ' % Guo ';
Third, group query
1. Group Sex
Select Sex,count(*fromgroup by sex;
2. Group sex Pre-condition query
Select Sex,count(*fromwhere!=' Li Bai 'group by sex;
3. Group Sex after conditional query
Select Sex,count(*fromgroupby hascount (*)>5;
4. Group after query and then condition query
Select Sex,count(*fromwhere!=' li Bai ' Groupby hascount(*)>5;
Four, sort query
1. Descending sort
Select * from Order by desc;
2. Descending and Ascending sort
Select * from Order by desc ASC;
Five, aggregate function
Count (*) sum (Salary) avg (Salary) min (Salary) Max (Salary)
MySQL Query statement