Oh, I see - that's rather different. What you need is first to split out all the words into one per row like this:
Code:
word
----
dog
dog
dog
dog
cat
cat
cat
tail
tail
and
ate
my
Then of course it is easy to group and count the words. But how to split them up? If you could be
sure there were no more than N words in any sentence then you could use a brute-force approach with a user-defined function like this:
Code:
select get_word(field1,1) as word from table1
union all
select get_word(field1,2) as word from table1
union all
...
union all
select get_word(field1,N) as word from table1
However, that probably isn't what you need. I don't know MySQL at all, but in Oracle you could achieve this (without the "N" words limit) by writing a function that returns a collection (like an array), and then selecting from the results of the function - a fairly complex operation.
It
may be that this can't be done in MySQL using just a select statement - you may have to write a program that populates a temporary table with all the words, and then select from that.