SQL之多个字段拼接

 

#第一种仅做多个字段拼接
select bid || ocpc_level_desc || pay_mode_desc AS fem_bid from fem_baidu_adgroup
#用concat函数多个字段拼接
select concat(bid,ocpc_level_desc,pay_mode_desc)AS fem_bid from fem_baidu_adgroup
#用concat函数并且/分隔
select concat(bid,'/',ocpc_level_desc,'/',pay_mode_desc)AS fem_bid from fem_baidu_adgroup
#用concat函数 case when判断值是否为空不为空时用/分隔
concat(bid,(case ocpc_level_desc when '' then ''else '/'end),ocpc_level_desc,(case pay_mode_desc when '' then ''else '/'end),pay_mode_desc) AS fem_bid,

 

你可能感兴趣的:(mysql)