SQL executes an INSERT INTO query, inserting multiple rows of records

Source: Internet
Author: User
Tags web hosting

What if we want to insert multiple lines of records? You might want to run the INSERT statement multiple times, just like the following PHP code example:

INSERT into Tbl_name (col1,col2) VALUES (.);

What if we want to insert multiple lines of records? You might want to run the INSERT statement multiple times, just like the following. NET code example:

New StringBuilder ();            Strsql.append ("INSERT into Tbl_name (col1,col2) VALUES (15,16); " );            Strsql.append ("INSERT into Tbl_name (col1,col2) VALUES (15,16); " );......

Oh, so the code efficiency is very low, it will seriously occupy the computer resources, if it is the while (5,000 = = $a), it is necessary to execute the database query, WOW plug! Boy! If you use PHP to build a website and use a shared web hosting, you can expect that your site will soon be dead. This is a crime, then how to write to improve efficiency? I don't know if you've ever used MySQL's visual management tools phpMyAdmin or other database management software, when backing up a database, a. sql file is generated, which is a bunch of SQL statements, which you can look at with the INSERT statement:

INSERT into ' usertable ' (' user_id ', ' user_name ') VALUES (1'dsf'), (  2'fgy'), (3'faad' );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.