How to count the number of times a string appears in a database field.
February 21, 2008 10:30 AM
Subscribe
SQL Filter: What query can I use to count the number of times a word appears in a text field?
I've got this table with ~500 records. The records have a specific text field that I'm interested in. Before I start a fairly involved find-and-replace project, I want to know:
a. how many records will need to have the find-and-replace function performed (I think I've got this one, using the 'LIKE' operator)
and
b. for a given record, how many instances of the find-and-replace operation will need to happen?
For example, if I were changing the word 'cat' to the word 'dog', I'd want to know how many times the word 'cat' appeared in a given field for each record.
I know I could query the db and parse the results with PHP, but I was looking for a solution I could run from the mysql 'command line'.
posted by Wild_Eep to computers & internet (6 comments total)
1 user marked this as a favorite
posted by d4nj450n at 10:40 AM on February 21, 2008