MySQL database records related to operations ---

sequence  

Related operations recorded in the table a total of four types: insert, update, delete, query. Which use the most, the most difficult is the query.

 

Record inserted

1. Insert the complete data (inserted sequence) 
syntax a: 
the INSERT the INTO table name (field 1, field 2, field 3 ... Field n) VALUES (value 1, value 2 and value 3 ... n-value); 

Syntax two: 
the INSERT the INTO table name vALUES (value 1, value 2 and value 3 ... value n-); 

2. insert the specified field data 
syntax: 
the iNSERT the INTO table name (field 1, field 2, field 3 ...) vALUES (value 1, value 2 and value 3 ... ); 

3. insert multiple records 
syntax: 
the iNSERT the INTO table name the vALUES 
(value 1, value 2 and value 3 ... value n-), 
(value 1, value 2 and value 3 ... value n-), 
(value 1, value 2, value 3 ... n-value);  

example:

insert into db1 values(1, "aaa", 20, "male");

insert into db1 values(1, "aaa", 20, "male"), (2, "bbb", 22, "female");

 

Update records

SET UPDATE table = Value 1 Field 1, Field 2 = value 2, WHERE CONDITION;

 example:

update db1 set name = "ccc" where name = "aaa";

 

Delete records

DELETE FROM 表名 WHERE CONITION;

 example:

delete from db1 where name ="xxx";

 

Record query

 Expect

 

Guess you like

Origin www.cnblogs.com/chusiyong/p/11404933.html