请问,如果我在一个表tb1里存了A,B,C,D四个数
我想要的结果是我select tb2 表,要的结果是tb2的一列,然后是tb1的一列
但是tb1是随机从表中取一个数,请问应该怎么写?
tb2 tb1
1    c
2    a
3    d
4    a
tb1是随机的

解决方案 »

  1.   

    select top 1 * from 表 order by newid()
      

  2.   

    我可能说没清我的意思,我的意思是这样create table tb1 (id,varchar(10))
    insert into tb1 
    select 'a'
    union all
    select 'b'
    union all
    select 'c'
    union allcreate table tb2 (randnum,varchar(10))
    select '1'
    union all
    select '2'
    union all
    select '3'我要的结果是要tb1的列,然后加上tb2的列,不过tb2的列的值是随机从 1,2,3里选一个结果的样子
    a    1
    b    2
    c    3不过1,2,3是随机从tb2里取出来的