I have a list of products
CREATE TABLE products (
id int,
description varchar(1000)
);
I want to search the description
with this term cool black shirt
. If any of these words appear in the description, I want it to show in the results. I also want it to be sorted by the how well it was matched from the search term. I am unsure how to do this.
The first challenge I am having is how can I split the term with spaces to create the LIKE
bit. I am only given the string cool black shirt
. I can't add each word manually. Needs to be automatic.
The second challenge I face is how do I sort the results by how well it matched the original term.
SELECT * from products
WHERE description LIKE 'cool black shirt'
ORDER BY ...;