Home >Backend Development >PHP Tutorial > mysql条件应用or查询不会触发索引

mysql条件应用or查询不会触发索引

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:39:57938browse

mysql条件使用or查询不会触发索引?
说法是:where条件中出现了or,不会使用索引


我测试结果如下:

<br />
mysql> explain select * from emp where ename="dsleos" or ename="saesad" \G<br />
*************************** 1. row ***************************<br />
           id: 1<br />
  select_type: SIMPLE<br />
        table: emp<br />
         type: range<br />
possible_keys: e_i<br />
          key: e_i<br />
      key_len: 62<br />
          ref: NULL<br />
         rows: 2<br />
        Extra: Using where<br />
1 row in set (0.00 sec)<br />


触发了索引,,到底使用or会不会触发索引啊?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn