0

I have two mysql tables search_words(id,word) and search_text_data(id,text) I need to find the count of words from search_words which appear in the text rows in search_text_data For eg. if the word in search_words is "family", then i want to find the count of how many times the word appeared in the text field in search_text_data

select a.id, a.word, count(b.id)
from search_words a , search_text_data b
where b.text like "%a.word%"

I know the above query is not the right syntax Need mysql query syntax that would do this.

1 Answer 1

2

I think this is what you want:

select sw.id, sw.word, count(std.id)
from search_words sw left outer join
     search_text_data std
     on std.text like concat('%', sw.word, '%')
group by sw.id, sw.word;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.