MySQL Inserting data

Source: Internet
Author: User

Inserting data using Insert

    • Insert a full line
    • Insert part of a row
    • Inserting multiple lines
    • Insert the results of some queries
Insert the full line first look at the original customer list:

Insert one line: INSERT into Customersvalues (NULL,' Pep E. Lapew ',' Main Street ',' Los Angeles ',' CA ',' 90046 ',' USA ',NullNULL);


There is also a way to specify the column name, which, when the structure of the table changes, its SQL statements can still be used, and this assignment does not need to be the same as the original structure of the table.

Inserting more than one row inserts multiple rows to tie together several INSERT statements:
INSERT ..... VALUES (,,,,);
INSERT ..... VALUES (,,,,) so that you can insert two records, and if you want to insert a column with the same name, you can merge the INSERT statement as follows:
INSERT into name (,,,,,,,)//subsequent insertion of multiple records with the same column name values (,,,,,,,,,), (...), (...), (.); This will insert three records.
Inserting the retrieved data is actually retrieving the data using the SELECT statement, which is inserted into the table as values, and it is well understood that the following SQL statement merges the Custnew table into the Customer table:
INSERT into Customers (cust_id,Cust_contact,Cust_email,Cust_name,Cust_address,Cust_city,Cust_state,Cust_zip,Cust_country) SELECT cust_id,Cust_contact,Cust_email,Cust_name,Cust_address,Cust_city,Cust_state,Cust_zip,Cust_countryfrom custnew;





Related Article

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.