I want to limit a string field length in MYSQL on a certain length, but I don\'t want any chopping up of words to occur.
When I do:
SELECT SUBSTRING(
Seems like people don't read the mysql manual:
Original: SELECT SUBSTRING('Business Analist met focus op wet- en regelgeving', 1, 28) gives broken words.
Modified: SELECT SUBSTRING_INDEX('Business Analist met focus op wet- en regelgeving', ' ' , 4) gives unbroken words
SUBSTRING_INDEX(string, delimiter, number) will truncate a string by the number of times delimiter is found.
Make your delimiter a space and you will get whole words only. so:
SUBSTRING_INDEX( LEFT('Business Analist met focus op wet- en regelgeving',28), ' ' , 4) should do it.