我需要一个查询来生成两个表格之间的比较表。使用SQL比较两个表格
事情是这样的:
TABLE_1:
col1 | col2 | col3
a | 1 | a_comment
b | 2 | b_comment
TABLE_2:
col1 | col2 | col3
a | 3 | a_comment
c | 4 | c_comment
查询结果:
col1 | table_1.col2 | table_2.col2 | col3
a | 1 | 3 | a_comment
b | 2 | NULL | b_comment
c | NULL | 4 | c_comment
另外,我需要保持秩序,S.T.如果col1中的x在col1中的任何一个表中的col1之前,它也将在查询结果之前。 我试图用FULL JOIN做它,但它重复col1和col3。
谢谢!
如果table_1和table_2对于col3具有不同的值,会发生什么情况? – Matthew 2011-02-16 16:24:38