0

我是 MySQL 的新手。请帮我找出我做错了什么。使用这个Mysql:按喜欢排序?问题我试图订购我的行,但结果与没有订购一样。这是一个查询示例:

SELECT * FROM sc_products
WHERE name_ru = 'water' 
OR name_ru like 'water%' 
OR name_ru like '% water%' 
OR name_ru like '\"water%' 
OR brief_description_ru like '%water%' 
OR product_code like '%water%'  
OR product_code in (select product_code from ALLPRODUCTS where searchfilter like '%water%') 
OR product_code in (select product_code from SC_products prd JOIN SC_product_manufacturers mnf ON prd.manufacturerID=mnf.manufacturerID where mnf.filters like '%water%')
ORDER BY CASE
    WHEN (name_ru = 'water' AND 
            name_ru like 'water%' AND 
            name_ru like '% water%' AND 
            name_ru like '\"water%' AND 
            brief_description_ru like '%water%' AND 
            product_code like '%water%') 
    THEN 1
    ELSE 2 
END

我没有找到另一个地方来回答我的问题。对不起。

4

1 回答 1

0

您应该在 CASE 中使用 OR 而不是 AND

于 2013-07-02T08:10:12.927 回答