Gossamer Forum
Home : General : Databases and SQL :

How many words?

Quote Reply
How many words?
I've been asked how many pages a database of mine would be if all the content was printed out. It has around 2000 records, each of which has an article. The articles' lenght varies, from 250 words to several thousand words, so I can only guess a rough estimate

Is there a SQL query that can tell me how many words are in a database (all tables, some tables)?
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