SELECT * FROM table WHERE product like '%abc%' OR product like '%cde%'
是否可以显示所有带有
both 'abc' and 'cde' first
然后用
either 'abc' or 'cde'
最佳答案
ORDER BY
一个case
表达式,如果abd和cde都返回1,否则返回2。
SELECT *
FROM table
WHERE product like '%abc%' OR product like '%cde%'
ORDER BY case when product like '%abc%' AND product like '%cde%' then 1
else 2
end
关于php - 如何选择具有指定值的列并按出现次数的指定值对它们进行排序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40763141/