0426-mysql insert statement Daquan

/*Note:
1. Fields and values ​​should be in one-to-one correspondence
2. The data type of the value is the data type of the field
3. When the input field is all the fields in the table, the field can be omitted or not written:
insert into login values ​​('zhangsan ','123','Zhang San', 1);
4. When not all fields, the fields must be written (if the primary key is not self-incrementing, it must be added):
insert into login(userid,password) values ​​('zhangsan','123 ');
5. When adding multiple pieces of data, separate them with commas;
insert into login(userid,password,username,sex) values ​​('zhangsan','123','Zhangsan',1),('lisi',' 456','Li Si',1);
*/ #Method

1:
insert into login(userid,password,username,sex) values ​​('xiaohong','123','Xiaohong',1); #Method
2 :
insert into zuoye1(id,f4) values ​​(1001,'Xiaohong');
insert into login(userid,password) select id,f4 from zuoye1; #Method
3:
insert into login set userid = '000',password = 'nihao';

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324898985&siteId=291194637