1. General Enquiry
SELECT * from info; #查询所有内容
Select Code,name from Info #查询某几列
2. Conditional query
SELECT * from Info where code= ' P001 ' #条件查询
SELECT * from Info where Nation = ' n001 ' and sex= true #条件之间并的关系
SELECT * from Info where Nation = ' n001 ' and sex = ' 1 '
SELECT * from Info where Sex = False or Nation = ' n002 ' #条件之间或者的关系
3. Fuzzy query (search keywords)
SELECT * from chinastates where areaname like '% ' #查询以中开头的
SELECT * from chinastates where areaname like '% City% ' #查询包含 City info
SELECT * from chinastates where areaname like ' _ City% ' #查询城 data appearing in the second position
4. Sorting
SELECT * from Car ORDER BY Code DESC #desc降序 ASC Ascending
SELECT * from Car ORDER by Brand
SELECT * from Car ORDER by Brand,powers #按照两个列排序
5. Statistical queries (aggregation functions)
Select COUNT (*) from Car #查询总条数 * represents all columns
Select COUNT (Code) from Car #查询某一列
The maximum value of the Select Max from Car #查询 the price joins
Select min (Price) from Car #查询最小值
Select AVG (price) from Car #查询平均值
Select SUM (Price) from Car #查询总和
6. Group queries
Select Brand,count (*) from Car GROUP by Brand #根据系列 Group (group) view the number of data bars per group
Select Code,brand,count (*) from Car GROUP by Brand #根据Brand分组查看Code, brand data bar
SELECT * FROM Car GROUP by Brand have Count (*) >2 #查询分组之后数据条数大于2的, group cannot add where
7. Paging Query
SELECT * from Car limit 0,5 #查询跳过0条 Take 5 strips
SELECT * from Car limit 5,5 #跳过几条取几条数据
MySQL Simple query