0x00: Preface.
There are two tables, one table field is Id-email, the other table field is ID-PWD, you want to merge the two tables with SQL script, because the same ID can match.
0x01: Example.
A field Id:email
650) this.width=650; "src=" Https://s5.51cto.com/oss/201711/13/5862387deaaa4307156e3147caa6e2f7.png "style=" float: none; "title=" Email.png "alt=" 5862387deaaa4307156e3147caa6e2f7.png "/>
Another field is Id:pwd
650) this.width=650; "src=" Https://s5.51cto.com/oss/201711/13/18816f1c5a263666ee374f63a16b0909.png "style=" float: none; "title=" Pwd.png "alt=" 18816f1c5a263666ee374f63a16b0909.png "/>
The desired output is the result ID:Email:PWD
650) this.width=650; "src=" Https://s2.51cto.com/oss/201711/13/eb848a705359845706c5ae04a790f6ce.png "style=" float: none; "title=" Out.png "alt=" Eb848a705359845706c5ae04a790f6ce.png "/>
The 0x02:mysql statement.
Note: Because MySQL is safe, one line is not allowed to execute two statements (for example: Linux under &&).
Writes the statement to the SQL script file before execution, and the file suffix with. sql,tttt_test is the database name.
650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/13/ccf410d7798d3df1375220ace613bcbf.png-wh_500x0-wm_3 -wmp_4-s_3857505506.png "title=" Out_test.png "alt=" Ccf410d7798d3df1375220ace613bcbf.png-wh_ "/>
The following is the text.
CREATE TABLE OUT1 as SELECT a.id,a.email,b.pwd from e-mail a INNER JOIN pwd b on a.id = B.id;delete A, from email a INNER JOIN pwd b on a.id = b.ID;
This article is from the "Enlightened Grocery store" blog, please be sure to keep this source http://wutou.blog.51cto.com/615096/1981338
MySQL two table same ID match, output to new table, delete old table match