Microsoft Access 2003 SQL问题

Microsoft Access 2003 SQL问题,sql,ms-access,null,union,Sql,Ms Access,Null,Union,我需要在Microsoft Access中合并几个具有不同结构的表 例如,我有一个表: table1 (column_a,column_b,column_c), table2 (column_a,column_c), table3 (column_d) SQL如下所示: SELECT table1 column_a,column_b,column_c, Null as column_d FROM Table1 UNION SELECT table2 column_a,Null as colum

我需要在Microsoft Access中合并几个具有不同结构的表

例如,我有一个表:

table1 (column_a,column_b,column_c),
table2 (column_a,column_c),
table3 (column_d)
SQL如下所示:

SELECT table1 column_a,column_b,column_c, Null as column_d FROM Table1
UNION
SELECT table2 column_a,Null as column_b, column_c, Null as column_d FROM Table2
UNION
SELECT table3 column_a, Null as column_b, Null as column_c, Null as column_d 
FROM Table3;
但有时MS Access会显示有关不兼容类型的错误消息

我认为这是因为在一个SELECT中具有空值的生成列的类型与另一个SELECT中相应的非自动生成列的类型不兼容


有没有办法用null指定自动生成列的类型?

用空字符串替换null怎么样

e、 g


你为什么需要工会?如果不是数据按摩/导入操作,则看起来像是架构问题。
SELECT col_a, col_b,       col_c,       '' as col_d FROM Table1
UNION
SELECT col_a, '' as col_b, col_c,       '' as col_d FROM Table2
UNION
SELECT col_a, '' as col_b, '' as col_c, '' as col_d FROM Table3;