Sql-insert A statement to perform multiple data insertions

Source: Internet
Author: User

There are three ways to do this:

1. InSert  into < table name >(column name)Select< column name >from< source table name >

Such as:

INSERT  into  SELECT  sname,saddress,semail from Students This method requires a new table to be built first.


2.

Select (column name)  into < table name >from< source table name >


Such as:

SELECT Students.sname,students.saddress,students.semail  into Tongxunlu  from Students This method SQL auto-Build table



3.

InSert  into < table name >(column name)Select< column name >Union Select < column name >Union ...


Such as:

INSERTSTUDENTS (sname,sgrade,ssex)SELECT 'Zhang can',7,1 UNIONSELECT 'Li Yang',4,0 UNIONSELECT 'Yang Xiao',2,0 UNIONSELECT 'Tang Mei',3,0 UNIONSELECT 'Su Sandong',7,1 UNIONSELECT 'Wang Li',3,1 UNIONSELECT 'Zhang Wei',7,1 UNIONSELECT 'Chen Gang',4,1 UNIONSELECT 'Wang Juan Juan',7,0

Sql-insert A statement to perform multiple data insertions

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.