Home > database >  Access the same table A and B two structure, how to query the data do not match all of the fields?
Access the same table A and B two structure, how to query the data do not match all of the fields?

Time:09-26

Two tables, the key word is ID, table structure is same data, how the two inconsistent data query the table? Need to record all of the fields is not the same are found out; The query result export excel format,

thank you

CodePudding user response:

1, create a new query, use the following SQL statement

Select the table 1. The field 1, table 1. Field 2, table 1. 3 the from field to table 1
Where the where not the exists (select 1 from table 2 table 1. The field 1=table 2. Field 1 and table 1. Field 2=table 2. Field 2 and table 1. Field 3=table 2. Field 3)
Union all
Select the table 2. The field 1 and table 2. Field 2, table 2. The field 3 from table 2
Where not the exists (select 1 from table 1 where table 1. The field 1=table 2. Field 1 and table 1. Field 2=table 2. Field 2 and table 1. The field 3=table 2. The field 3)

2, can use macros, do an export Excel function, select export source for the above query can
  • Related