In an MySQL query I have this line in the SELECT statement:
IF(LENGTH(adr.klantnaam) > 20, LEFT(CONCAT(adr.klantnaam,'..'),20), adr.klantnaam) AS klantnaam,
It shortens the text in the field bit it won’t add the dots (..) at the end when the string is shortend.
How to change my code?
You need to do
CONCAT(LEFT(adr.klantnaam,20),'..')Otherwise you’re adding the dots to the name (which you know is over 20 characters) before trimming, so it will always trim the dots off as well.
(If you want to end up with 20 characters, you could trim klantnaam to 18 chars, and then add the dots)