Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Can I count occurences (not rows) of a word?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-09 : 08:02:57
Beetrader writes "Dear gurus everywhere!

Can I use SQL to count the occurences of a word in a text column?

I don't want to count the number of rows. If the word "flower" occurs twice in one row and once in another row, I want the counter to tell me there are 3 hits (word occurrences), not 2 (relevant rows).

Theoretically I guess I could load each text field into an ASP or PHP script and do the counting there, but in reality the data transfers would kill the computers. So the counting must be done in the database and I pray it is possible. Is it?

I also need to learn how to count the total number of words in a set. Is it possible? So if the first text has 50 words and the second has 25, I can get a figure from the database saying 75? (A workaround might be to count the blanks between the words but I still need to learn how it is done best.)

(I will then divide the number of flowers by the total number of words to get a figure of how probable the word is to appear.)


Grateful regards,
Beetrader
slask@fornyelsebutiken.com"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-09 : 08:53:43
Have you read this article?

http://www.sqlteam.com/item.asp?ItemID=5857

It should do the trick.

Go to Top of Page
   

- Advertisement -