错误的MYSQL结果

错误的MYSQL结果,mysql,Mysql,我这里有一个var_转储查询,它显示了一个错误的结果 select p.* , case when p.specials_new_products_price >= 0.0000 and (p.expires_date > Now() or p.expires_date IS NULL) and p.status != 0 then p.specials_new_products_price else p.products_price

我这里有一个var_转储查询,它显示了一个错误的结果

select p.*
, case when p.specials_new_products_price >= 0.0000 
  and (p.expires_date > Now() or p.expires_date IS NULL) 
  and p.status != 0 then 
      p.specials_new_products_price 
  else 
      p.products_price 
end price 

from wp_global_products_table p 
INNER JOIN wp_blogs s ON s.blog_id = p.blog_id 
where p.products_name like '%indifi%' 
or p.products_description like '%indifi%' 
and s.countries_id = '168' 
and global_category_id = '15' 
and p.display_product = '1' 
and p.products_status = '1' 
order by p.products_date_added DESC, p.products_name"
这是原始查询

$catglobal_sql = "select p.*, case when p.specials_new_products_price >= 0.0000 and (p.expires_date > Now() or p.expires_date IS NULL or p.expires_date ='0000-00-00 00:00:00') and p.status != 0 then p.specials_new_products_price else p.products_price end price from ".TABLE_GLOBAL_PRODUCTS." p INNER JOIN ".TABLE_STORES." s ON s.blog_id = p.blog_id where MATCH (p.products_name,p.products_description) AGAINST ('%".$search_key."%') ".$country_q." ".$zone." ".$currency_type." ".$search_cat." and p.display_product = '1' and p.products_status = '1' ".$duration." ".$product_type." ".$price_range." order by p.products_date_added DESC, p.products_name";
if (!mysql_num_rows(mysql_query($catglobal_sql))) {
$catglobal_sql = "select p.*, case when p.specials_new_products_price >= 0.0000 and (p.expires_date > Now() or p.expires_date IS NULL) and p.status != 0 then p.specials_new_products_price else p.products_price end price from ".TABLE_GLOBAL_PRODUCTS." p INNER JOIN ".TABLE_STORES." s ON s.blog_id = p.blog_id where p.products_name like '%".$search_key."%' or p.products_description like '%".$search_key."%' ".$country_q." ".$zone." ".$currency_type." ".$search_cat." and p.display_product = '1' and p.products_status = '1' ".$duration." ".$product_type." ".$price_range." order by p.products_date_added DESC, p.products_name";
}
比如说,在搜索数据库中可用的“Indifi”时,Indifi的
global\u category\u id
的值为3

正如您在var_转储结果中所看到的,
global_category_id
为15,因此不应显示“Indifi”,但它会显示


我的查询应该有什么问题?

尝试使用括号:

...where (p.products_name like '%indifi%' 
or p.products_description like '%indifi%')
and s.countries_id = '168'
... 
这样你们就不会在一起玩得太多了

where p.products_name like '%indifi%' OR p.products_description like '%indifi%' and s.countries_id = '168' and global_category_id = '15' and p.display_product = '1' and p.products_status = '1'
我在那里看到了一个
,因此如果
p.products\u名称像“%indifi%”
,那么
global\u category\u id是什么并不重要


要确定优先级,请使用括号
(…或…

我没有看到这一点。。谢谢你,我没看见。。非常感谢。