Gossamer Forum
Home : General : Databases and SQL :

Re: [gotze] How many words?

Quote Reply
Re: [gotze] How many words? In reply to
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
Subject Author Views Date
Thread How many words? gotze 4767 Mar 6, 2004, 3:57 PM
Post Re: [gotze] How many words?
cornball 4386 Mar 20, 2004, 12:29 AM