Insert a table record
1 Inserting a data insert
Insert [INFO] table_name (field name, ... VALUES (value: )
2 inserting more than one data
Insert [INFO] table_name (field name, ... VALUES (value: )
(Field name, ... VALUES (value: )
(Field name, ... VALUES (value: )
。。。。。。
(Field name, ... VALUES (value: )
Two modified table records
UPDATE table_name SET field = value, field = value ... where sentence;
Three Delete table records
Delete from table_name where sentence;
TRUNCATE TABLE table_name; #将表全部删除, and then create a new table, and the fields are the same.
Four-view table records
View Syntax:
SELECT * |field1,filed2 ... From Tab_name
Where condition
Group BY Field
Have by field
Limit number of bars
The WHERE clause can be used:
Comparison operators:
> < >= <= <>! =
Between N1 and N2 values between N1 to N2
The In (N1,N2,N3) value is N1 or N2 or N3
What does like '% ' start with?
Or and not or with non-
ORDER BY clause:
Selest * | Field1,field2 .... From Tab_name order by filed [ASC | DESC]
--asc Ascending, Desc descending, where ASC is the default value the ORDER BY clause should be located in the
Select group field name, Sum (field name [int]) from Order_menu Group by Group field name
Select group field name, sum (number [int]) from Order_menu Group by Group field name having condition;
/* have and where both can be further filtered query results, the difference is: <1>where statement can only be used in the filter before grouping, having can be used in the filter after grouping; <2& gt; You can use the WHERE statement where you can replace the <3>having with an aggregate function, where it does not work. */
Aggregation functions:
Number of statistics Count:
Select count (field name) from Examresult;
Select count (field name) from Examresult where condition;
Content and sum (field name) for rows that meet the criteria:
Select SUM (field name "requires number Type") from Examresult;
Averaging AVG (field name):
Select AVG (field name "requires number Type") from Examresult;
Max, Min Max, min:
Select max (field name requires number type) from Examre;
Select min (field name "requires number Type") from Examre;
The end of the SELECT statement.
Limit clause:
SELECT * from Examresult limit number;
SELECT * from Examresult limit number, number;
RegExp using:
SELECT * FROM employee where emp_name regexp ' ^yu '; Start with what?
SELECT * FROM employee where emp_name regexp ' yuan$ '; At what end?
SELECT * FROM employee where Emp_name regexp ' m{2} '; Take a few
From big to small:
Take maximum
41st Day of walking into the computer (database 2 table records operations)