Fatie表  authorId和lastEditorId都是bigInt型的fatie表里有authorId(userid),lastEditorId(userid) authorId和lastEditorId为0时,显示 '游客' 否则显示姓名 authorId和lastEditorId

解决方案 »

  1.   

    select case when authorid=0 then '游客' else ltrim(authorid) end,
         case when lastEditorId=0 then '游客' else ltrim(lastEditorId) end
    from [Fatie]
      

  2.   

    select case when authorId=0 and lastEditorId=0 then '游客' else authorName end from Fatie
      

  3.   

    select authorId=case when authorId=0 then N'游客' else authorId end ,lastEditorId =case when lastEditorId =0 then N'游客' else lastEditorId end 
    from fatie
      

  4.   


    这个方法可以,我想问下为什么加了ltrim就不会报错了我之前是这么写的
    select 
    case when author=0 then '游客' else author end
    from TLiuYanFaTie可是老报错:
    服务器: 消息 8114,级别 16,状态 5,行 1
    将数据类型 varchar 转换为 bigint 时出错。
      

  5.   

    select case when authorId=0 and lastEditorId=0 then '游客' else authorName end from Fatie
      

  6.   

     这昨天不是刚问过?
    http://topic.csdn.net/u/20081022/16/e922d867-d42d-4ee2-bb3f-6c3c8559d225.html