MySQL: is AND conditional or logical? [duplicate]

岁酱吖の 提交于 2019-12-25 02:16:29

问题


If I run such a query in MySQL:

SELECT field FROM table WHERE field1=42 AND field2 LIKE '%beer%';

Will every row be parsed for having "beer" in field2 or only those whose field1=42?


回答1:


That depends on the query plan and what indexes you have on the table. Try putting EXPLAIN before your query and MySQL will tell you more. Generally speaking though, if field1 is indexed, then LIKE should only be performed for those rows where field1 is 42.



来源:https://stackoverflow.com/questions/8790245/mysql-is-and-conditional-or-logical

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!