Home >Database >Mysql Tutorial >How to insert data in mysql
MySQL data insertion is the operation of adding new records to the database. The syntax is: INSERT INTO table_name (column1, column2, ..., columnN) VALUES (value1, value2, ..., valueN); Steps Includes: 1. Specify the target table name; 2. List the columns to be inserted; 3. Provide column values. For example, the following query will insert a record containing the following information into the customer table: INSERT INTO customer (id, name, email) VALUES (5, 'John D
MySQL data insertion
Inserting data is one of the most important operations in MySQL, which allows developers to add new records to the database.
Syntax
<code class="sql">INSERT INTO table_name (column1, column2, ..., columnN) VALUES (value1, value2, ..., valueN);</code>
Steps
table_name
is the target table into which you want to insert data.column1
, column2
, ..., columnN
is the column you want to insert Provide the column of values. value1
, value2
, ..., valueN
is you The values to insert. The values must be compatible with the data type of the specified column. Example
The following query will insert a new record containing the following information To the customer
table:
<code class="sql">INSERT INTO customer (id, name, email) VALUES (5, 'John Doe', 'john.doe@example.com');</code>
Other Notes
LAST_INSERT_ID()
function to get the ID of the recently inserted record. <code class="sql">INSERT INTO customer (id, name, email) VALUES (5, 'John Doe', 'john.doe@example.com'), (6, 'Jane Smith', 'jane.smith@example.com'), (7, 'Mark Jones', 'mark.jones@example.com');</code>
The above is the detailed content of How to insert data in mysql. For more information, please follow other related articles on the PHP Chinese website!