Answer the question
In order to leave comments, you need to log in
How to correctly compose an SQL query using order by case?
Hello. It is required that the output result be sorted by the maximum occurrence of words in the product title. I'm trying this option:
SELECT * FROM products
order by case
when title LIKE "%Спиннинг%" AND title LIKE "%Карбоновый%" AND title LIKE "%Белый%" AND active = 1 then 1
when title LIKE "%Спиннинг%" AND title LIKE "%Карбоновый%" AND active = 1 then 2
when title LIKE "%Спиннинг%" AND active = 1 then 3
else 4
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question