Tim Van Wassenhove

Passionate geek, interested in Technology. Proud father of two

18 Jan 2006

Select the first 50 words of an article

I am cleaning up my code snippets and i found the following little trick in one of them that i have removed. Assuming that different words are separated by spaces we can use SUBSTRING_INDEX as following

SELECT SUBSTRING_INDEX(body,' ',50) AS dn FROM mytable