Home : General : Databases and SQL :

General: Databases and SQL: Re: [gotze] How many words?: Edit Log

Here is the list of edits for this post
Re: [gotze] How many words?
Hello gotze,

counting words in a field may be tried with [ depends on SQL database ]

SELECT (1 + LENGTH(Field_Name) - LENGTH(REPLACE(Field_Name, ' ', ''))) AS Word_Count from Table_Name

-- you supply Field_Name and Table_Name in above.

-- may not work [ not tested ] with double spaces between words and / or foreign character sets.


And to total all the words in a field for the table try :

SELECT
sum((1 + LENGTH(Field_Name) - LENGTH(REPLACE(Field_Name, ' ', '')))) AS Word_Total from Table_Name

Have a try.

Thanks cornball

Last edited by:

cornball: Mar 20, 2004, 12:32 AM

Edit Log: