I use SUBSTRING_INDEX quite a lot on Eccommerce sites where for a listing of products I would like to extract a certain number of words from the actual product description:
SUBSTRING_INDEX('description', ' ' , 20) AS shortDesc
In most case this works like a charm! But there are those moments that the actual product description is devided in paragraphs. If in those cases the number of words in the first paragraph doesn't match the number of words in the SUBSTRING_INDEX, words from the second paragraph are added until it reach the number of words but with this the space between the paragraphs is included in my output. Is there any way to avoid this?
Thank you in advance