简体   繁体   English

如何合并两个表中具有相同列的两个表,以识别MySQL中的差异?

[英]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 我不是很精通MySQL:我的问题是我有两个表:t1和t2

t1 11

Name, ID  

t2 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. 我想合并仅包含ID的t1和t2列,并确定为什么我在这些ID上有区别。

You can investigate the mysql function MERGE 您可以调查mysql函数MERGE

An other alternative would be to add the column types in t1 and update it to add missing data. 另一种选择是在t1中添加列类型,并对其进行更新以添加丢失的数据。 I assume here your types type is VARCHAR(60): 我在这里假设您的类型类型是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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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