1.如下表结构;表ActivitySteps:
字段: from int,to int表数据:
from to
a b
b c
c d2.
如何通过一个sql查询,获得如下查询结果:
a
b
c
d3.
因此得到的结果是有顺序的,请问这个如何操作啊?
盼赐教!!
字段: from int,to int表数据:
from to
a b
b c
c d2.
如何通过一个sql查询,获得如下查询结果:
a
b
c
d3.
因此得到的结果是有顺序的,请问这个如何操作啊?
盼赐教!!
select distinct col
from(
select [a] as col from tb
union
select [b] as col from tb
)t
order by col
a和b是你表tb的两个字段。
create table t( fr char(10),too char(10)
)
drop table t
insert into t
select 'a','b'
union all
select 'b','c'
union all
select 'c','d'
select aa from
(select fr as aa from t
union
select too as aa from t) a