sql里数据库存的是整数我想显示对应的中文,怎么处理呢;用sql语句怎么写?就是table1 有一字段    Inout  整型  
表数据里存的是0和1我想查询出来0变为  进  1变为出怎么处理?

解决方案 »

  1.   


    select case 字段名  when 0 then  '进'  when 1 then  '出' end 
    from tb
      

  2.   

    select case when 字段=0 then N'进' ELSE N'出' end
      

  3.   


            case when Inout=1 then '进' esle '出' end
      

  4.   

    select 1-字段 from tb
      

  5.   

    select case Inout when 0 then '进' else '出' end from tb 
      

  6.   

    select replace(replace(Inout ,0,'进'),1,'出')
      

  7.   

    表里还有其它字段也要查出呢;
    并且inout 有0,1,2,3几种情况;字段有 name  inout time
      

  8.   

    select case Inout when 0 then '进' else '出' end,name,inout ,time from tb 呗
      

  9.   

    多谢大家,在大家启发下亲自测试得出如下,都可以,我的数据库中inout是自符形的SELECT Time, name, 
          (CASE InOut WHEN '0' THEN '进' WHEN '1' THEN '出' WHEN '2' THEN '进无效' when '3' then '出无效' END)
    FROM table1或SELECT Time, name, 
          (CASE InOut WHEN 0 THEN '进' WHEN 1 THEN '出' WHEN 2 THEN '进无效' when 3 then '出无效' END)
    FROM table1