对于 case....when 的用法

对于poi导出时候的1转化为汉字,可以写判断,当然在sql里面写更好,如下:
/ /在查询的时候如果值为o导出来就变成不允许,值为1 就变成允许,否则其他都是为选择,如果我们还接着往后拼接2,3,4,只需要加 when 0 then '不允许' 这个即可;



"select case is_redeem when 0 then '不允许' when 1 then '允许' ELSE '未选择' END is_redeem2," +
"t.* FROM bee_product t where 1=1"); //bee_product 为表名
//is_redeem 为字段名,当然我们要保证后面的字段名要同前面的字段名不一致,当我们在下面引用的时候要引用后面的字段名;




具体代码;
sql.append("select case is_virtual when 0 then '实际产品' when 1 then '虚拟产品'ELSE '未选择' END is_virtual2," +
"case is_soldout when 0 then '在售' when 1 then '已售' ELSE '未选择' END is_soldout2," +
"case is_show when 0 then '显示'when 1 then '不显示' when 2 then '待显示' ELSE '未选择' END is_show2," +
"case del_flag when 0 then '是' when 1 then '否' ELSE '未选择' END del_flag2," +
"case is_continue when 0 then '不支持续投' when 1 then '支持续投' ELSE '未选择' END is_continue2," +
"case is_continue_product when 0 then '不支持' when 1 then '支持' ELSE '未选择' END is_continue_product2," +
"case continue_status when 00 then '不支持续投' when 01 then '不续投' when 02 then '本金续投' when 03 then '本息续投' ELSE '未选择' END continue_status2," +
"case product_type when 0 then '优选'when 1 then '阶梯' when 2 then '红包' ELSE '未选择' END product_type2," +
"case is_redeem when 0 then '不允许' when 1 then '允许' ELSE '未选择' END is_redeem2," +
"t.* FROM bee_product t where 1=1");
//ider:外部传入一个表头、SQL语句、
String s[] = new String[] { "id", "company_id", "product_name",
"term", "term_status", "base_profit", "extra_profit1","extra_profit2","coupon_pools","is_soldout2","total_amount",
"current_amount","bought","min_investment","max_investment",
"is_virtual2","is_show2","del_flag2","start_date","end_date",
"is_continue2","is_continue_product2","continue_status2",
"wlc_product_id","product_code","product_tip","product_desc","xieyi_hylink",
"agreement_id","remark","product_type2","product_place","buy_hylink","group_relation",
"is_redeem2","borrow_page"};
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值