考虑下面列出的表格
Table credit
id cr_amount created_date
1 1000 2011-07-01
2 2000 2011-07-08
3 6000 2011-07-09
以下是Table debit
条目。
id dr_amount created_date
1 3000 2011-07-09
需要阅读cr_amount
排序的上表中的dr_amount
,created_date
和created date
列,如下所示。
cr_amount dr_amount created_date
1000 NULL 2011-07-01
2000 NULL 2011-07-08
6000 NULL 2011-07-22
NULL 3000 2011-07-09
答案 0 :(得分:2)
您可能需要将两列都放在union all中:
select cr_amount,Null as 'db_amount',created from table_credit
union all
select Null,db_amount,created from table_debit
order by created