0

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?

dotancohen
  • 30,064
  • 36
  • 138
  • 197

1 Answers1

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.

Michael Mior
  • 28,107
  • 9
  • 89
  • 113