目前油价两个表 A 和 A_history 两个表的列顺序不同A_history 是 A 的历史记录现在要将两个表做union后的结果集作为一个整体用于查询eg.select * from c, (A + A_history)as aa where c.id = aa.id
不过在oracle里好像不行的
请问应该怎么写这个sql语句啊
不过在oracle里好像不行的
请问应该怎么写这个sql语句啊
union all
select B.* from A_history B
union
select f1, f2, f3 ... from a_his
select * from a
union all
select * from b
]
另外,楼主的语法在ORACLE中是不能执行的。
[code=SQL]
select * from c, (A + A_history)as aa where c.id = aa.id
连接字符串ORACLE 不是 +号 是用 ||
考虑到效率问题。建议用 UNION ALL
因为你用UNION ORACLE执行的是有也是先执行 UNION ALL 然后再去重复。
这样反而慢了。