MySQL uses the INSERT statement to insert data into the table. The syntax is: INSERT INTO
( <column name>, ... ) VALUES (
, ... ). Parameters include: : the name of the table into which data is to be inserted; <column name>: the name of the column into which data is to be inserted;
: the value in the column to be inserted. For example, to insert a row of data into a table named employees: INSERT INTO employees (id, name, email) VALUES (1, 'John Doe MySQL Add Data Statement
The statement used to insert data into the table in MySQL is the
INSERT
statement.Syntax:
<code class="sql">INSERT INTO <表名> ( <列名>, ... ) VALUES ( <值>, ... );</code>Parameters:
<Table Name>
: The name of the table into which data is to be inserted.<Column name>
: The name of the column to be inserted into, which can be a single column or multiple columns.<Value>
: To insert the value in the column, it can be a single value or multiple values.Usage example:
Suppose we have a class named
employees
table, which contains three columns:id
,name
and<code class="sql">INSERT INTO employees (id, name, email) VALUES (1, 'John Doe', 'john.doe@company.com');</code>Note:
- The order of the inserted values must be consistent with the order of the columns in
<Column Name>
.- If
<column name>
is not specified, the value will be inserted into all columns in the table.- If you want to insert a
Rows can be inserted multiple times using theNULL
value, you need to specify # in the value ##NULL.
- VALUES()
clause, as shown below:
<code class="sql">INSERT INTO employees (id, name, email) VALUES (2, 'Jane Doe', 'jane.doe@company.com'), (3, 'John Smith', 'john.smith@company.com');</code>The above is the detailed content of How to write mysql add data statement. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cnPrevious article:How to open mysql database with cmd commandNext article:How to open mysql database with cmd command