有没有这样的查询select table1.col1,table2.col1
from table1,table2
where table1.col1满足条件1 && table2.col1满足条件2而table1 table2之间也没什么关系 我是想同时显示无数据,看起来方便的那种,有这种格式的么?
from table1,table2
where table1.col1满足条件1 && table2.col1满足条件2而table1 table2之间也没什么关系 我是想同时显示无数据,看起来方便的那种,有这种格式的么?
--sql server 2000
--col1 < t.col1 , col2 < t.col2也可以换为关键字 < t.关键字
select m.col1 , n.col2 from
(select col1 , px = (select count(1) from tb1 where 条件1 and col1 < t.col1) + 1 from tb1 where 条件1) m
full join
(select col2 , px = (select count(1) from tb2 where 条件2 and col2 < t.col2) + 1 from tb2 where 条件2) n
on m.px = n.px
--col1 < t.col1 , col2 < t.col2也可以换为关键字 < t.关键字
select m.col1 , n.col2 from
(select col1 , px = (select count(1) from tb1 where 条件1 and col1 < t.col1) + 1 from tb1 where 条件1) m
full join
(select col2 , px = (select count(1) from tb2 where 条件2 and col2 < t.col2) + 1 from tb2 where 条件2) n
on m.px = n.px
--sql server 2005,用row_number()函数解决,order by col1,order by col2可以换为order by 关键字
select m.col1 , n.col2 from
(select col1 , px = row_number() over(order by col1) from tb1 where 条件1) m
full join
(select col2 , px = row_number() over(order by col2) from tb2 where 条件2) n
on m.px = n.px