1. Simple query
SELECT * from info;
Select Code as ' Code ', name as ' name ' from info;
2. Conditional query
SELECT * from car where code = ' c002 ';
SELECT * FROM car where brand = ' b001 ' and power = 130; #或用or
3. Fuzzy query
SELECT * from car where name like '% Audi% '; % represents any number of characters including 0 _ for one character
4. Sort queries
SELECT * FROM Car order by brand, Powers Desc; ASC Ascending default can not write
5. Scope Query
SELECT * from car where price between and 60;
6. Discrete query
SELECT * from car where code in (' Coo1 ', ' c003 ', ' c005 ', ' c007 ');
SELECT * from car where code not in (' coo1 ', ' c003 ', ' c005 ', ' c007 ');
7. Statistical queries (aggregation functions)
Select count (code) from car; Query data Bar count (*) can also be written so that performance is low
Select SUM (price) from car; Sum
Select Max (code) from car; Biggest
Select min (brand) from car; Minimum
Select AVG (price) from car; Average
8. Paging Query
SELECT * from Car limit (n-1) *5,5 #第n页, showing five data per page
9. Go to re-query
Select distinct Brand from Car
10. Group queries
Select Brand,count (*), brand from Car GROUP by Brand #把brand列的相同值组合起来, and this data operates on the column or other columns such as averaging
Select brand from Car GROUP by Brand have Count (*) >3 #分组之后根据条件查询使用having do not use where
MySQL various queries