word counts from text field

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
harsh789
Forum Newbie
Posts: 4
Joined: Fri Jun 09, 2006 12:11 pm

word counts from text field

Post by harsh789 »

Hi,

I want to calculate the numbers of occurances of a word in a text type table filed in mysql query.

For ex. say filed name 'content' in a 'pages' table have value "This is a very good web site", then query for "is" word shoud return 2.

Thanks for your valuable help.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

The first thing that came to mind is to make your search a regular expressions, then throw it and the string you're searching at preg_match_all().
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply