gpt4 book ai didi

Mysql,Concat指定长度

转载 作者:行者123 更新时间:2023-11-29 01:08:00 25 4
gpt4 key购买 nike

我试图在 mysql 函数中找到一种方法来执行以下操作:

'ssssssttttttttrrrriiiinnnngggg' // I have this string

我只想取 10 个字母然后连接“...”(3 个点),但我只想连接到超过 10 个字母的字符串,例如:

'123456string' // Will result: '123456stri...'
'strin6' // Will result: 'strin6'
'str123456ing' // Will result: 'str123456i...'
'asd23456' // Will result: 'asd23456'

我正在尝试 substr、lpad 和 concat 组合,如果有人得到正确的函数组合,我将非常感激,谢谢大家,祝你有美好的一天。

最佳答案

  select case when length(mystring) <= 10 then 
mystring
else
concat(left(mystring, 7), '...')
end as mycol
...

关于Mysql,Concat指定长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16564607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com