简体   繁体   中英

How to merge two tables having the same column in both the tables in order to identify the discrepancies in MySQL?

I am not very proficient in MySQL: My questions is I have two tables: t1 and t2

t1

Name, ID  

t2

ID, types

I want to merge both t1 and t2 only columns containing the ID's and identify why I have the difference in these ID's.

You can investigate the mysql function MERGE

An other alternative would be to add the column types in t1 and update it to add missing data. I assume here your types type is VARCHAR(60):

ALTER TABLE table ADD [COLUMN] types VARCHAR(60);

UPDATE t1,t2 SET t1.types=t2.types WHERE t1.ID=t2.ID;

DROP TABLE t2;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM