Create an insert select from statement in oracle to make sure that one of the two tables has the same field as other different fields.

Source: Internet
Author: User

Due to the need of work, today we have encountered a problem: teachers in the educational administration system use the original employee number. Due to new needs, teachers now have a new employee number, now let's do one thing: Make an excel table that lists the name of the teacher, the new employee number, and the old employee number ......

If it is handled manually, the workload of many teachers is too large, so the database is used for processing, because these teachers have a unique and unique name.

Take the following two methods:

1) directly query information that lists the XM, XGH, and JGH fields (XM: name, XGH: New Employee ID, JGH: old employee ID)

 

New1 table XM and XGH fields, new2 table XM and JGH Fields

SQL: select n1.xm, n1.xgh, n2.jgh from new1 n1, new2 n2 WHERE n1.xm = n2.xm

The result is as follows: copy and paste it to excel to solve this problem.

 

 

 

2) I will insert XM, XGH, and JGH into a new table new, and then export the excel file.

SQL: insert into new (xm, xgh, jgh) select n1.xm, n1.xgh, n2.jgh from new1 n1, new2 n2 WHERE n1.xm = n2.xm

 

 

Just Insert the new table, and export the excel file.

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.