razin kac
razin kac

Reputation: 83

Count word in text column in MySQL

This question is about MySQL Query. I have three tables:

  1. brand (consists of: text)
  2. englishkeyword (consists of ID, word)
  3. englishkeywordmodel (consists of: ID, score)

I want to count how many words in 'text' with the word which is already determined in 'word'. Then the result is stored in 'score'. This is my code:

UPDATE englishkeywordmodel
SET score=(SELECT COUNT(*)FROM brand WHERE text LIKE (SELECT word FROM englishkeyword WHERE ID=2 LIKE ('%', word, '%')))
WHERE ID=2;

I got this error:

1241 - Operand should contain 1 column(s)

I say many thanks for answer!

Upvotes: 1

Views: 384

Answers (1)

Abhishek Sharma
Abhishek Sharma

Reputation: 6661

Use LIMIT because Your subquery is selecting two or more columns

SELECT word FROM englishkeyword WHERE ID=2 AND Column LIKE
CONCAT('%', word ,'%')  limit 1

Upvotes: 2

Related Questions