表中某一字段为整型.如这个字段的值1为成功,2为失败,0为未知.
用select 语句时怎么能把这个转化成我想要的就是显示成功,失败,未知,看到的不是0,1,2这样的数字.

解决方案 »

  1.   

    select '成功' from  test where aa=0
    uinon
    select '失败' from  test where aa=1
    uinon
    select '未知' from  test where aa=2
      

  2.   

    DECLARE @cStatus varchar(1), @iRetCode intselect @cStatus=.........查询语句IF @cStatus='1' SELECT @iRetCode=0
    IF @cStatus='2' SELECT @iRetCode=-1SELECT @iRetCode在程序里调用 if ADOStoredProc1.Parameters[0].value = 0 then
        showmessage('成功')
     else
        showmessage('失败');
      

  3.   

    问题已解决:
    select personid,type=case type
      when 0 then '未知'
      when 1 then '失败'
      when 2 then '成功'
    end
    from jb700log
      

  4.   

    select case 字段名 when 0 then '成功' when 1 then '失败'  when 2 then '未知' end from 
    test
    用SQL中的CASE语句就行了
      

  5.   

    SELECT CASE 字段名WHEN 0 THEN '成功' WHEN 1 THEN '失败' WHEN 2 THEN '未知' END AS 字段别名
     FROM 表名
      

  6.   

    select personid,type=case (case type
      when 0 then '未知'
      when 1 then '失败'
      when 2 then '成功'
    end) as 你的别名
    from jb700log
      

  7.   

    To:xuminghua(企鹅) 
      好像不行啊????
    提示:
    在关键字 'as' 附近有语法错误。