SQL语句技巧,怎样查询才高效?
A表 B表
Aid(P) amount Aid(F) amount
2 100 2 15
3 200 2 30
4 150 5 1000
5 8000
要得到一下结果
1 100
2 15
2 30
3 200
4 150
5 8000
5 1000
最原始的查询
select aid,amount from A
union all
select a.aid,b.amount from a,b where a.aid(+) = b.aid
但是当A表是一个很复杂的查询是,对效率影响很大.