根据字符数插入称呼

问题描述 投票:0回答:1

在称呼大于15个字符的情况下,将在字段中插入“Hi”字样

考虑使用正则表达式函数,但不知道如何实现它

当regexp_like(称呼,>'^ [0-9] {15} $')然后'嗨'

MR Nigel Humphreys  -> "hi"
Ms Montjoy          ->  "Ms Montjoy"
Mr Fitz-Lloyd Smith -> "hi"
sql impala
1个回答
2
投票

length()case怎么样?

select (case when length(salutation) > 15 then 'hi'
             else salutation
        end) as new_salutation

如果要实际覆盖该字段,则需要更新:

update t
    set salutation = 'hi'
    where length(salutation) > 15;
© www.soinside.com 2019 - 2024. All rights reserved.