mysql - Add dots if string has more than 10 words -


i want return preview of texts getting first 10 words.

concat(substring_index(q.value, ' ', 10), '...') preview 

this works great when string long. should not added when string shorter (because there nothing more).

is possible 100% mysql?

you can use case:

select (case when substring_index(q.value, ' ', 10) = q.value              q.value              else concat(substring_index(q.value, ' ', 10), '...')         end) 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -