• notice
  • Congratulations on the launch of the Sought Tech site

Mysql inserts multiple data instances in a time

Let’s create a table Authors first:

CREATE TABLE Authors(
AuthID SMALLINT NOT NULL PRIMARY KEY,
AuthFN VARCHAR(20),
AuthMN VARCHAR(20),
AuthLN VARCHAR(20)
)
ENGINE=INNODB;

Then insert multiple pieces of data into the table at once, the sql insert code is as follows:

INSERT INTO Authors VALUES (1006,'H','S.','T'),
              (1007,'J','C','O'),
              (1008,'B', NULL,'E'),
              (1009,'R','M','R'),
              (1010,'J','K','T'),
              (1011,'J','G.','N'),
              (1012,'A', NULL,'P'),
              (1013,'A', NULL,'W'),
              (1014,'N', NULL,'A');

In fact, it is very similar to inserting SQL statements one by one, except that multiple insert statements use a comma to separate each piece of data.

The results are as follows:

AuthID AuthFN AuthMN AuthLN
1006 H S. T
1007 J C O
1008 B   E
1009 R M R
1010 J K T
1011 J G. N
1012 A   P
1013 A   W
1014 N   A

Thank you for reading, I hope to help everyone, thank you for your support to this site!

Tags

Technical otaku

Sought technology together

Related Topic

1 Comments

author

cost lipitor 10mg & lt;a href="https://lipiws.top/"& gt;order lipitor 10mg generic& lt;/a& gt; oral lipitor 80mg

Xqqecb

2024-03-09

Leave a Reply

+