col
1
2
3
要求结果
col1 col2
1      2
1      3
2      3

解决方案 »

  1.   

    --这個?
    create table T(id int)
    insert into T select 1
    insert into T select 2
    insert into T select 3
    insert into T select 4
    insert into T select 5select a.id,b.id
    from T a,T b
    where a.id<b.id
    /*
    ------------
    1 2
    1 3
    2 3
    1 4
    2 4
    3 4
    1 5
    2 5
    3 5
    4 5*/drop table T
      

  2.   

    --try
    select * from 表名 a join 表名 b on a.col<b.col
      

  3.   

    select a.col,b.col from
      (select col from table_name ) as a ,(select col from table_name) as b
    where a.col<b.col
      

  4.   

    好象用cross join显得更专业,不过我不习惯,呵呵