We help IT Professionals succeed at work.
Get Started

SQL to find number of occurrences of a word in a column

zenguru asked
Last Modified: 2013-11-15
I have a table 'kws' in MySQL database:

id  BIGINT(20)  kw  VARCHAR(255)   terms VARCHAR(2048)

where id is the primary  key

I need to find the number of rows in which  the word contained in column kw is repeated 3 or more times in the column terms.

So what the raw SQL query for that?

kw contains the single word while terms contains multiple words that are delimited by ; ( it would be best if the query is not dependent on what type of delimiter is used). There are thousands of rows in the table.

Also what is the query to give all those rows in which column kw is repeated 2 or less times in the column terms. ( in this one  not return the count but return the actual row data)
Watch Question
SQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2019
This problem has been solved!
Unlock 4 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE