I was trying to find a way in mysql functions do the the following:
'ssssssttttttttrrrriiiinnnngggg' // I have this string
I want to take only 10 letters then concate '...'(3 dots), But i only want to concat to strings with over 10 letters so for example:
'123456string' // Will result: '123456stri...'
'strin6' // Will result: 'strin6'
'str123456ing' // Will result: 'str123456i...'
'asd23456' // Will result: 'asd23456'
I was trying substr, lpad and concat combinations, If anyone got the correct functions combination i will be very thankful, Thank you all and have a nice day.
select case when length(mystring) <= 10 then
mystring
else
concat(left(mystring, 7), '...')
end as mycol
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With