查询条件非空为‘0’,空且不为“无”或“不是”则为‘1’怎么写

解决方案 »

  1.   

    select case when col is not null then '0' else '1' end from tb
      

  2.   

    select case when col is null or col = '' then '1' else '0' end from tb
      

  3.   

    查询条件非空为‘0’,空且不为“无”或“不是”则为‘1’怎么写 select case when col is not null then 0 when col is null and col not in('无','不是') then 1 else col end
    from tb
      

  4.   

    select
      case when col is not null then 0
           when col is null and not in('无','不是') then 1
      end
    from
      tb
      

  5.   

    空且不为“无”或“不是”则为‘1’既然是空了,就肯定不会是'无','不是'等其他内容.也许楼主说反了.
    条件应该是:
    非空且不为“无”或“不是”为‘0’,空或者无,不是则为‘1’select case when col is null or col in {'无','不是'} then '0' else 1 end from tb以上这些SQL语句,楼主自己选个合适的吧.
      

  6.   

    忘记说我用的是ACCESS,只能用IFF
      

  7.   

    你的问题都没描述清楚,还分什么access和sql