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>Copy after loginParameters:
<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>Copy after loginNote:
- 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>Copy after loginThe 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!
Related labels:source:php.cnPrevious article:How to open mysql database with cmd command Next article:How to install mysql after downloading itStatement of this WebsiteThe 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.cnLatest Articles by Author
2024-11-21 18:07:47 2024-11-21 18:07:16 2024-11-21 18:06:52 2024-11-21 15:07:20 2024-11-21 15:07:08 2024-11-21 15:06:54 2024-11-21 15:06:40 2024-11-21 15:03:54 2024-11-21 15:03:44 2024-11-21 15:03:32Latest IssuesHow to group and count in MySQL? I'm trying to write a query that extracts the total number of undeleted messages sent to f...From 2024-04-06 18:30:1701353MySQL gets data from multiple tables I have a eg_design table which contains the following columns: and eg_domains table which ...From 2024-04-06 18:42:4402479Related TopicsMore>Popular RecommendationsPopular TutorialsMore>
JAVA Beginner's Video Tutorial2515294 Latest DownloadsMore>