Syntax
Update table name set column name = column value, column name = column Value ... [Conditions];
"Precautions"
* The value of the modified column needs to be consistent with the column type.
* The length of the value of the modified column cannot exceed the maximum length of the column type.
* String type and date type require single quotation marks.
"Modify some records in a database"
Modify all records in the database
To modify a record with ID 3
1.1.1.2 Delete operations on table records in the database
Syntax
Delete from table name [condition];
"Precautions"
Deleting deletes a record from a table and cannot delete data from a column (modifications are not deleted).
Delete Deletes the records in the table, and you cannot delete the entire table.
"Delete a record in a table"
"Delete and truncate comparison"
Delete from table name, and TRUNCATE table name; All records in the table can be deleted.
* Delete Deletion is a single piece to delete. TRUNCATE TABLE deletes the entire table and re-creates the same table.
* Transaction management can be used on DML (INSERT,UPDATE,DELETE) statements. Transactions can be rolled back. Know
1.1.1.1 Query operations on table records in the database (* * * * *)
"Basic Syntax"
SELECT [DISTINCT] *| column name from table name [condition];
"Basic use of query statements"
CREATE TABLE Exam (
ID int primary KEY auto_increment,
Name varchar (20),
中文版 int,
math int,
Chinese int
);
INSERT INTO exam values (null, ' Liang ', 90,78,82);
INSERT INTO exam values (null, ' Liang ', 85,91,76);
INSERT INTO exam values (null, ' Liang Zhe ', 75,62,58);
INSERT INTO exam values (null, ' Zhang Feng ', 95,69,87);
INSERT INTO exam values (null, ' Li Ru flower ', 90,82,95);
Querying All records
Check the student's name and English score
Check the English scores of all students
Find out what all students have in English (remove duplicates)
Perform an expression operation in the query
Query the value of the student's total.
Query the student's name and the value of the total
"Query to column alias"
Use the AS keyword to alias a column
As can be omitted
"Conditional Query"
Grammar
SELECT [DISTINCT] *| column name from table where condition;
The wording of the condition after the WHERE clause:
Judging:>, <, >=, <=, =, <>
In (value 1, value 2, value 3)
Like fuzzy query. You need to use placeholders. There are two types of placeholders-the other is%.
_ Represents a character Zhang _; White
% stands for any character of the sheet; White
Enquiries about students with English scores greater than 90 points:
Query Math score is 62,78,69 classmate information:
To inquire about students surnamed Liang:
The side of the condition:
* and, OR, not
The student information that queries the surname Beam and whose English score is greater than or equal to 90.
Student information with a beam in the query name and a total score greater than 250:
Take you for a spin. Javaweb development of six-mysql Basic grammar and examples (3)