I want to sort results based on the number of matching words in two strings (case insensitive). Is there a way given two strings to count the number of matching words that appear in both strings?
Example:
"Red blue black green", "Green Black Blue"
-> 3
"Blue Green", "green blue"
-> 2
"Blue Green", "Red blue"
-> 1
"green blue black", "orange purple"
-> 0
I want to use this in an Order By clause. Given that a table has a column with a string in it, I'll query that table, then order the results based on the rows with the most matching words in the passed in string.