Mysql uses insert to insert multiple records to add data in batches

Mysql uses insert to insert multiple records to add data in batches

If you want to insert 5 records into table1, the following is wrong:

INSERT INTO table1 (id,name) VALUES(1,Xiaoming,2,Xiaoqiang,3,Xiaodu,4,Xiaoli,5,Xiaobai);

MySQL will throw the following error

ERROR 1136: Column count doesn't match value count at row 1

The correct way to write it should be like this:

INSERT INTO table1(i,name) VALUES(1,'Xiao Ming'),(2,'Xiao Qiang'),(3,'Xiao Du'),(4,'Xiao Li'),(5,'Xiao Bai');

Of course, you can also omit the column name in this way, so the number of values ​​in each pair of brackets must be the same, and this number must be consistent with the number of columns. like:

INSERT INTO table1 VALUES(1,'Xiao Ming'),(2,'Xiao Qiang'),(3,'Xiao Du'),(4,'Xiao Li'),(5,'Xiao Bai');

Summarize

The above is what I introduced to you about using insert in Mysql to insert multiple records in batches of new data. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Examples of 4 methods for inserting large amounts of data in MySQL
  • MYSQL batch insert data implementation code
  • Tutorial on implementing batch inserts in MySQL to optimize performance
  • How to avoid MySQL batch inserts with unique indexes
  • Detailed example code of mysql batch insert loop
  • MySQL batch insert data script
  • Detailed explanation of MySQL batch SQL insert performance optimization
  • MySql batch insert optimization Sql execution efficiency example detailed explanation
  • MySQL batch inserts data through function stored procedures

<<:  How to Set Shortcut Icons in Linux

>>:  js to upload pictures to the server

Recommend

Reduce memory and CPU usage by optimizing web pages

Some web pages may not look large but may be very ...

Detailed tutorial on using the Prettier Code plugin in vscode

Why use prettier? In large companies, front-end d...

How to configure static network connection in Linux

Configuring network connectivity for Linux system...

Tutorial on building an FTP server in Ubuntu 16.04

Ubuntu 16.04 builds FTP server Install ftp Instal...

Summary of some tips on MySQL index knowledge

Table of contents 1. Basic knowledge of indexing ...

How to connect a Linux virtual machine to WiFi

In life, the Internet is everywhere. We can play ...

Six tips to increase web page loading speed

Secondly, the ranking of keywords is also related ...

A brief discussion on group by in MySQL

Table of contents 1. Introduction 2. Prepare the ...

Introduction to user management under Linux system

Table of contents 1. The significance of users an...

Implementation of building Kubernetes cluster with VirtualBox+Ubuntu16

Table of contents About Kubernetes Basic environm...

Docker deploys Laravel application to realize queue & task scheduling

In the previous article, we wrote about how to de...

Specific use of lazy loading and preloading in js

Delayed loading (lazy loading) and preloading are...

HTML reuse techniques

HTML reuse is a term that is rarely mentioned. Tod...