0423-mysql insert statement Daquan

1  /* Note:
 2  1. Field and value should be in one-to-one correspondence
 3  2. The data type of the value is the data type of the field
 4  3. When the input field is all the fields in the table, the field can be omitted or not written:
 5  insert into login values ​​('zhangsan','123','Zhang San', 1);
 6  4. When not all fields, the fields must be written (if the primary key is not self-incrementing, it must be added):
 7  insert into login(userid,password) values ('zhangsan','123');
 8  5. When adding multiple pieces of data, separate them with commas;
 9  insert into login(userid,password,username,sex) values ​​('zhangsan','123','Zhangsan', 1),('lisi','456','Li Si',1);
 10  */ 
11  
12 #Method 1  :
 13  insert  into login(userid,password,username,sex) values ​​( 'xiaohong ', ' 123 ' , ' Xiaohong ' , 1 );
 14 #Method  2:
 15  insert  into zuoye1(id,f4) values ​​( 1001 , ' Xiaohong ' );
 16  insert  into login(userid,password) select id,f4 from zuoye1;
 17 #Method  three:
 18  insert  into login set userid =  ' 000 ' , password =  ' nihao ' ;

 

Guess you like

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