Creating database: Create library name;
Creating Table: Create table table name (column name data type (length) primary key, column name data type is empty ... );
Note: Do not add commas to the last column. Multiple statements are executed together, plus semicolons. Code symbol half-width.
CREATE TABLE Keyword: primary key primary
Non-empty NOT NULL
Self-growing column auto_increment
Foreign key relationship foreign key (column name) references table name (column name)
Add data: INSERT into table name values (', ', ', ') in parentheses are the same as the number of columns in the table
Insert into table name (column name, column name) VALUES (",") to add the specified column
Modify data: Update table name set column = new value where condition;
Delete data: Delete from table where+ condition;
Normal query: Select (Result display column) from table name
Conditional query: Select (Result display column) from table name where condition
Sort query: Selert (Results display column) from table name order BY column name (ASC/DESC), column name (ASC/DESC) ...
Aggregate function: SELECT COUNT (*) from table name #取个数
Select SUM (column name) from table name #查询列的和
Select AVG (column name) from table name #查询平均值
Select Max (column name) from table name #查询最大值
Select min (column name) from table name #查询最小值
Paged Query: SELECT * FROM table name limit n,m #跳过n条取m条
Group query: Select Column name from table name Group By column name #简单的分组查询
Select brand from Car GROUP by Brand has count (*) >2 #查询系列里面车的数量大于2的系列
Go to re-query: SELECT DISTINCT column name from table name
Modify Column Name: Select column name as ' new column name ' from table name
Fuzzy query: SELECT * FROM table name where name like ' _ Audi% ' # any combination % represents an infinite character _ represents any combination of characters
Discrete query: SELECT * FROM table name where column name In/not in (', ' ', ')
greater than all data: SELECT * from table name where column name >all (50,40,30)
MySQL Simple Statement (2)