In mysql, you can use insertinto to insert records into the database. you can insert one or more records according to different statements. This article introduces how to use insertinto in mysql. First, let's take a look at the insert into syntax in mysql:
INSERT INTO table_name VALUES (value1, value2,....)
You can also specify the columns in which you want to insert data:
INSERT INTO table_name (column1, column2,...)VALUES (value1, value2,....)
Note: SQL statements are case-insensitive. Insert into is the same as insert.
Example 1: multiple groups of values can be inserted in an insert statement at a time. each group of values is enclosed by a pair of parentheses and separated by commas, as shown below:
insert into `news`(title,body,time) values('title 1','body 1',now()),('title 2','body 2',now());
Example 2: The Insert Select statement inserts the query result into a new table. as the name suggests, it consists of an insert statement and a select statement.
insert into news_one(id,title,body,time) select id,title,body,time from news_two;
When using php, note that the two tables have the same structure and different column names.
The code for the "insert. php" page is as follows: