MySQL insert data _ MySQL

Source: Internet
Author: User
INSERT data using INSERT a part of the complete row INSERT a part of the row INSERT multiple rows INSERT some query results INSERT a complete row first look at the original customer list: INSERT a row: INSERTINTOcustomersVALUES (NULL, PepELaPew, 10 INSERT data

Insert a part of the complete row insert multiple rows insert some query results insert the complete row first look at the original customer list:

INSERT a row: insert into mers values (NULL, 'Pep E. laPew ', '2014 Main Street', 'Los Angeles ', 'CA', '000000', 'USA', NULL, NULL );


Another way is to specify the column name. in this way, when the table structure changes, its SQL statement can still be used, and this assignment does not need to be the same as the original table structure.
INSERT multiple rows you can combine multiple INSERT statements:
INSERT... VALUES (,,,,);
INSERT... VALUES (,); in this way, you can INSERT two records. if the column names to be inserted are the same, you can merge the INSERT statements as follows:
Insert into name (,) // the same column name values (,) will be used for subsequent inserts of multiple records (,,,,,,,,,), (.........), (.........); // in this way, three records are inserted. Insert the retrieved data is to use the SELECT statement to retrieve the data and insert it into the table as the value of VALUES. the following SQL statement combines the custnew table into the customer table:
Insert into mers (cust_id, cust_contact, cust_email, cust_name, cust_address, region, cust_state, region) SELECT cust_id, cust_contact, upper, cust_name, cust_address, lower, cust_state, lower, cust_country FROM custnew;

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.