art15 Posted April 28, 2008 Share Posted April 28, 2008 Hi, I was wondering if it is possible to count the number of words in a field. for eg if i have a field called comment and i want to count number of words in the field comment? any idea? Thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted April 29, 2008 Share Posted April 29, 2008 Sadly, not really. Quote Link to comment Share on other sites More sharing options...
beebum Posted April 30, 2008 Share Posted April 30, 2008 A friend of mine wrote this: http://www.kfwebs.net/news/489/How-to-count-the-number-of-occurences-in-a-string Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted May 1, 2008 Share Posted May 1, 2008 There is a bit of a workaround... -- essentially we are determining the number of spaces in the string (by subtracting the length -- of the string without spaces from the length with) and dividing the number of spaces into the -- total number of characters SELECT LENGTH(column_name) / (LENGTH(column_name) - LENGTH(REPLACE(column_name, ' ', ''))) AS num_of_words FROM table_name It's not 100% accurate, but it'll pass. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 1, 2008 Share Posted May 1, 2008 Not a bad approximation. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.