請問這個語法怎么樣弄?如:表table中字段a有三筆資料,
             abc,
             ccc,
             edd想輸出一筆資料為acb;ccc;edd謝謝了

解决方案 »

  1.   

    declare @a varchar(1000)
    set @a=''
    select @a=';'+@a+a from 表
    set stuff(@a,1,1,'')
    print @a
      

  2.   

    修正下create table 表(a varchar(10))
    insert into 表
    select 'abc'
    union all select 'ccc'
    union all select 'edd'declare @a varchar(1000)
    set @a=''
    select @a=@a+';'+a from 表
    set @a=stuff(@a,1,1,'')
    print @a/*
    abc;ccc;edd
    */
      

  3.   

    insert into b values(select ta.a,tb.a,tc.c from table ta ,table tb, table tc where ta.a=tb.a and tb.a=tc.a)用表的自连接来实现
      

  4.   

    select ta.a,tb.a,tc.a from table ta ,table tb, table tc where ta.a=tb.a and tb.a=tc.a
    and ta.其他字段>tb.对应字段 and tb.对应字段>tc.对应字段
      

  5.   

    修正一下:select ta.a,tb.a,tc.a from table ta ,table tb, table tc where ta.a<>tb.a and tb.a<>tc.a and ta.a<>tc.a