繁体   English   中英

上一栏的Concat

[英]Concat from a previous column

我有办法从逻辑确定的前一列中合并一列吗?

    
    select
    if(p.mfg is not null , p.mfg, 'Private') as MFG,
    concat(MFG, " ",p.sku) as TITLE
    from product p

您可以使用CASE语句,例如

select
if(p.mfg is not null , p.mfg, 'Private') as MFG,
concat(case when p.mfg is not null then p.mfg else 'Private' end, " ",p.sku) as TITLE
from product p

(OR)使用inline view

select MFG, concat(MFG, " ", sku) as TITLE
from (select if(p.mfg is not null , p.mfg, 'Private') as MFG, sku from product p
    ) tab

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM