1. Add Content
INSERT INTO Info valuse (' poo1 ', ' Zhang San ', 1, ' n001 ', ' 1989-2-3 ')
Insert into info (code,name column name) valuse (' P002 ', ' John Doe ') must contain primary key
2. Delete data
Delete From info drop table
Delete from info where code= ' P002 '
3. Modify the data
Update info set name= ' John Doe ' all modified to John Doe
Update info set name= ' John Doe ' where code= ' p001 '
4. Querying data
(1) Simple query
SELECT * FROM info query All content * represents all columns
Select Code,name from info queries the specified column
Select Code as ' Code ', name as ' name ' from info queries the specified column and replaces the column name
(2) Conditional query
SELECT * from car where code= ' c002 ' single condition
SELECT * FROM car where Trun query all content
SELECT * from car where brand= ' b001 ' and pawers= ' 130 ' multi-criteria query and relationship
SELECT * from car where brand= ' b001 ' or pawers= ' or or relationship
(3) Fuzzy query
SELECT * from car where name '% Audi% '% stands for any number of characters _ represents an arbitrary character
(4) Sort query
SELECT * from Car order by powers Asc/desc Single column sort ASC ascending desce Descending default ascending, can not write ASC
SELECT * FROM Car ORDER BY brand Asc,powers desc ASC does not write double column sort
(5) Scope query
SELECT * from car where price>=40 and price<=60 60>= price >=40
SELECT * FROM car where prices between and 60>= price >=40
(6) Discrete query
SELECT * from car where code in (' c001 ', ' c003 ', ' c005 ', ' c007 ') is used to find code in (' c001 ', ' c003 ', ' c005 ', ' c007 ') if looking for non, with not in
(7) Aggregation function, statistical query
Select SUM (price) from car queries all prices sum sum () sums in car are not available for strings
Select COUNT (*) from car queries all data bars in CAR * can be replaced by column names available for strings
Select Max (price) from Car Query column maximum value available for string
Select min (price) from Car Query column minimum value available for string string null minimum
Select AVG (price) from car query average is not available for strings
(8) Paging query
Show x data per page, now fetch page n
SELECT * from Limit (n-1) *x, what to take
(9) Go to re-query
Select distinct brand from car remove the duplicate of brand
(10) Group query
Select COUNT (*), bround from car group by brand
Select brand from car GROUP by Brand have count (*) >3 after grouping according to conditional query use having, cannot use where
Adding and deleting, the most comprehensive