Insert data into mysql database. Previously commonly used INSERT INTO table name (column name 1, column name 2…) VALUES (column value 1, column value 2); If it is in a PHP program, it will be written as follows (adding products to the product library) $sql = "INSERT INTO products (p_title,p_price.........) VALUES ('$p_title','$p_price'............)"; The disadvantage is that when the table has a lot of columns, it will be very messy.
In fact, you can use INSERT INTO table name SET column name 1 = column value 1, column name 2 = column value 2,...; If it is in a PHP program, it will be written as follows (adding products to the product library): $sql = " INSERT INTO products SET p_title = '$p_title', p_price = '$p_price', ... "; This makes it clear and easy to check for errors. And it has some common parts with the update statement, which makes it easier to reuse. However, you cannot add data in batches using the INSERT INTO SET method. If you want to add data in batches, use this method (example) $sql = "INSERT INTO products (p_title,p_price) VALUES ('apple','5 yuan'),('lychee','10 yuan'),('red dates','8 yuan')"; The above is the advantages of INSERT INTO SET in MySQL that I would like to introduce to you. I hope it will be helpful to you. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Docker installation of Nginx problems and error analysis
>>: Essential knowledge for web development interviews and written tests (must read)
The parameter passed by ${param} will be treated ...
Table of contents 1. How to locate and optimize s...
This article uses examples to illustrate the prin...
This article uses examples to explain the princip...
Table of contents 1. Download the MySQL installat...
What is a mirror? An image can be seen as a file ...
Why do we need permission management? 1. Computer...
1. Download MySQL Workbench Workbench is a graphi...
MySQL stored procedures, yes, look like very rare...
There are many tasks to be done in search engine o...
Currently encountering such a problem My situatio...
This article uses examples to illustrate the func...
1. pc-reset PC style initialization /* normalize....
1. The ul tag has a padding value by default in M...
Last time, we came up with two header layouts, on...