当前位置: 代码迷 >> DB2 >> sql文的写法
  详细解决方案

sql文的写法

热度:2455   发布时间:2013-02-26 00:00:00.0
求一个sql文的写法
一张表table字段F1和F2

F1 F2
1 a  
2 b  
3

达成的效果:

1 a
1 b
2 a
2 b
3 a
3 b

求这个sql文 应该怎样写?小弟初学,麻烦各位大侠指教。

------解决方案--------------------------------------------------------
SELECT a.f1,b.f2 from tt a,tt b
where b.f2 is not null
------解决方案--------------------------------------------------------
SQL code
select a.f1,b.f2from table a,table border by a.f1,b.f2
------解决方案--------------------------------------------------------
SELECT a.f1,b.f2 from tt a,(select distinct f2 from tt) b 
where b.f2 is not null
------解决方案--------------------------------------------------------
引用不好意思 写错了这张表应该是这样的
  相关解决方案