mysql处理以逗号隔开的字段内容

有一个字段保存了CheckBox内容,比如职业目标选择对于数据库字段otWorkgoal,保存了1,2,3,4内容

现在需要使用纯mysql语句,将字段otWorkgoal根据内容,进行翻译成中文的内容。

可使用FIND_IN_SET()函数+concat_ws()函数实现。

FIND_IN_SET()可参考https://www.cnblogs.com/zxmceshi/p/5479892.html

 

concat_ws()可参考http://blog.csdn.net/desilting/article/details/38563087

 

具体的sql语句如下

select 
concat_ws(',',(select '为创业积累经验技能与资源' from online_person_info q where find_in_set('1', q.otWorkgoal) and t.id = q.id)
,(select '更高的职位晋升空间' from online_person_info q where find_in_set('2', q.otWorkgoal) and t.id = q.id) 
,(select '更好的薪酬待遇' from online_person_info q where find_in_set('3', q.otWorkgoal) and t.id = q.id)
,(select '更具挑战的工作内容 ' from online_person_info q where find_in_set('4', q.otWorkgoal) and t.id = q.id)
,(select '学习到更厉害的专业技能' from online_person_info q where find_in_set('5', q.otWorkgoal) and t.id = q.id)
,(select '更舒适的工作环境' from online_person_info q where find_in_set('6', q.otWorkgoal) and t.id = q.id)
,(select '减小工作压力' from online_person_info q where find_in_set('7', q.otWorkgoal) and t.id = q.id)
,(select '更近的上班距离' from online_person_info q where find_in_set('8', q.otWorkgoal) and t.id = q.id)
,(select '其他' from online_person_info q where find_in_set('9', q.otWorkgoal) and t.id = q.id)
) as otWorkgoal
from online_person_info t where t.id='61'

即可进行翻译

转载于:https://www.cnblogs.com/conswin/p/8125947.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值