I have a coding problem and was wondering if there is a SQL implementation of the following scenario:
I want to search in a text column for certain words and want to sort the results based on the number of individual words found. For example:
Let's find the row which contains: a b s
a b b c d e s
b d s w d a s
x d s g w d s
f e h w d s a
The desired result would be:
a b b c d e s (it contains all 3 words)
b d s w d a s (it contains all 3 words)
f e h w d s a (it contains 2 words)
x d s g w d s (it contains 1 word)
Is it recommended doing something like this rather in e.g. PHP or is there an efficient SQL way to do so?