How to insert MYSQL query results of two tables into a new table

Source: Internet
Author: User

The following describes how to insert a new table into the MYSQL query results of two tables. This method is for your reference. If you have encountered any problems in MYSQL query result processing, take a look.

Table
+ ------------------- +
| Id | user | info |
| 1 | u1 | 991 |
| 3 | u3 | 113 |
+ ------------------- +
Table B
+ ------------------- +
| Id | user | pw | pw2 |
| 1 | u1 | p1 | p12 |
| 2 | u2 | p2 | p22 |
| 3 | u3 | p3 | p32 |
+ ------------------- +

Can I create A new table using A statement and convert it into the following results? excluding the IDs that are not in Table B but not in Table A and merging the data with the same ID? Of course.

 
 
  1. +-------------------------+  
  2. |id |user |pw1 |pw2 |info |  
  3. |1  |u1   |p1  |p12 |991  |  
  4. |3  |u3   |p3  |p33 |113  |  
  5. +-------------------------+ 

Implementation statement for inserting the MYSQL query results of two tables into the new table

 
 
  1. view sourceprint?1 create table jieguo2 SELECT t1.id, t1.user,t1.pwd,t1.pwd2,t2.user2,t2.info FROM t1 INNER JOIN t2 ON t1.id = t2.id  

The above describes how to insert the MYSQL query results of the two tables into the new table.

Command for viewing the Mysql table structure

About date format conversion functions in MySQL Query

Implementation of querying the first letter of Chinese characters and Pinyin in MySQL

Optimization instance for MySQL random Query

MySQL query cache Variables

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.