select * from (select * from a union select * from b) order by c
TO leoyb(冰点): 有必要再嵌一层吗?
C在表A中是2 3 1 C在表B中是2 4 3 合并排序后应该是1 2 3 2 3 4 order by c 是不是对表A和表B分别进行排序。
select c,.... from a union select c,..... from b;不确信是否是按c排序的 但union后结果应该是已经排序的select * from ( select c,.... from a union select c,..... from b ) order by c ;是可以的
我想得到的排序结果是123234, rainy你的结果是122334,不行啊。
呵呵,你的意思我终于明白了,我也有过同样的问题: select * from (select 1,A.* from A union select 2,B.* from B) order by 1,c; 没试过,应该可以,如果有问题,告诉我,我再修改。
(select * from a
union
select * from b)
order by c
有必要再嵌一层吗?
3
1
C在表B中是2
4
3
合并排序后应该是1 2 3 2 3 4
order by c 是不是对表A和表B分别进行排序。
union
select c,..... from b;不确信是否是按c排序的
但union后结果应该是已经排序的select * from (
select c,.... from a
union
select c,..... from b
)
order by c ;是可以的
rainy你的结果是122334,不行啊。
select * from
(select 1,A.* from A union
select 2,B.* from B)
order by 1,c;
没试过,应该可以,如果有问题,告诉我,我再修改。