MYSQL中IF IN语句
以下代码摘自后台管理系统中的一部分SQL语句:
当取数状态为1或2时,才展示取数时间,否则,取数时间展示为空
当申报状态为2、3、4或5时,才展示申报时间,否则,申报时间展示为空
select A.QYMC,C.DZBDMC,B.SKSSQQ,B.SKSSQZ,B.NSQXDM,B.QSBZ, if(B.QSBZ in ('1','2'),B.QSSJ,'') as QSSJ, if(B.SBZT in ('2','3','4','5'),B.SBSJ,'') as SBSJ, B.SBZT,B.KKZT,B.CXSBBZ,B.UUID, case B.NSQXDM when '20' then '月' when '30' then '季' when '40' then '年' when '41' then '半年' when '50' then '次' end as NSQXDM1, case B.QSBZ when '0' then '未取数' when '1' then '取数' when '2' then '需要重新取数' end as QSBZ1, CASE B.SBZT when '0' then '未申报' when '1' then '申报中' when '2' then '已申报' when '3' then '申报成功' when '4' then '申报失败' when '5' then '发现已完成申报' end as SBZT1, CASE B.KKZT when '0' then '未扣款' when '1' then '扣款中' when '2' then '已扣款' when '3' then '扣款成功' when '4' then '扣款失败' when '5' then '无需扣款' end as KKZT1, CASE B.CXSBBZ when '0' then '未撤销' when '1' then '撤销中' when '2' then '已撤销' when '3' then '撤销成功' when '4' then '撤销异常' end as CXSBBZ1 FROM tp_qyxx_qyxx A, tp_sw_sbwcqkb B, tp_dm_dzbd_dzbdgl C WHERE A.QYNBM = B.QYNBM and B.DZBDBM = C.DZBDBM AND {#condition#}