比较两个相似表中多列中不匹配的值 [英] Comparing Two Similar Tables for Unmatched Values in Multiple Columns

查看:78
本文介绍了比较两个相似表中多列中不匹配的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表具有完全相同的列字段,我想比较TableA到TableB中大约15列的值,以确定哪个主ID在一个表中具有与第二个不匹配的值。换句话说,我想看看TableA中主要ID的第2-15列是否与表B中的相同主ID相匹配。要比较的列中的所有值都是数字。我想要一个可以返回任何和所有差异的解决方案。如果我需要进一步解释,请告诉我。

I have two tables with exactly the same column fields and I''d like to compare the values across about 15 columns from TableA to TableB to determine which Primary ID''s have values in one table that do not match the second. In other words I''d like to see if columns 2-15 for a Primary ID in TableA match columns 2-15 for the same Primary ID in TableB. All values in the columns to be compared are numeric. I''d like a solution that would return any and all discrepancies. Please let me know if I need to explain further.

推荐答案

尝试这样的事情:

Try something like this:

展开 | 选择 | Wrap | 行号


这看起来不错,但是,我收到一个错误编译错误:expected:case。我仍然非常擅长编码,只能编辑和调整其他代码。在您提供的代码之前或之后,我有什么遗漏的东西吗?粗体部分是有错误的地方。我真诚地感谢你的帮助!!




SELECT TableA.PrimaryKey,


IIf(TableA.Field1<> TableB。 Field1,X,,AS Field1Check,

IIf(TableA.Field3<> TableB.Field3," X","")AS Field3Check
FROM TableA INNER JOIN TableB

ON TableA.PrimaryKey = TableB.PrimaryKey;
This looks great, however, I''m getting an error "compile error: expected: case". I''m still extremely new to coding and have only been able to edit and tweak other codes. Is there something I''m missing before or after the code you provided? The bold sections are where there are errors. I sincerely appreciate your help!!



SELECT TableA.PrimaryKey,

IIf(TableA.Field1<>TableB.Field1,"X","") AS Field1Check,
IIf(TableA.Field2<>TableB.Field2,"X","") AS Field2Check,
IIf(TableA.Field3<>TableB.Field3,"X","") AS Field3Check
FROM TableA INNER JOIN TableB
ON TableA.PrimaryKey = TableB.PrimaryKey;


这只是一个SQL语句,不应该在VBA模块中。这是为了查询 - 而不是VBA代码。
This is merely a SQL statement and should not be in a VBA module. This is to buld a query--not VBA code.


这篇关于比较两个相似表中多列中不匹配的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆