MySQL被忽略的地方

Bro*_*rob 0 mysql

有谁知道为什么在这个查询中忽略发布的索引?

SELECT news.id, news.slug, news.title, news.created_on FROM (news) 
WHERE `published` = '1' 
AND news.title LIKE '%running%' 
OR news.body LIKE '%running%' 
OR news.intro LIKE '%running%' 
ORDER BY created_on desc
Run Code Online (Sandbox Code Playgroud)

Ang*_*chs 6

我会假设OR正在造成它.在OR连接的三个语句周围尝试括号.

像这样:

SELECT news.id, news.slug, news.title, news.created_on FROM (news) 
WHERE `published` = '1' 
AND (
     news.title LIKE '%running%' 
  OR news.body LIKE '%running%' 
  OR news.intro LIKE '%running%' 
)
ORDER BY created_on desc
Run Code Online (Sandbox Code Playgroud)