I have this PHP code:
if ((strlen($str) > 120)){
$str = substr($str, 0, strpos($str, ' ', 110)).' ...';
}
As you know, my code cuts the string based on the space. I mean it never ends up with cutting a word in the middle.
Anyway, I want to know, can I do the same thing in MySQL?
Based on some researches, I figured out there is a MySQL function for such job, something like this:
SELECT SUBSTR(col, 0, 110), other_cols
But as you know, it does't care about the space and might breaks a work.