WHERE LIKE中的Mysql顺序优先级

时间:2013-07-02 08:07:16

标签: sql case sql-like

我是MySQL的新手。请帮我看看我做错了什么。 使用这个Mysql: Order by like?问题我尝试命令我的行,但结果与没有排序相同。 这是一个查询示例:

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

我的问题没找到另一个地方。遗憾。

1 个答案:

答案 0 :(得分:0)

你应该在CASE

中使用OR代替AND