SQL - Does the order of WHERE conditions matter?

前端 未结 5 1572
误落风尘
误落风尘 2020-11-29 06:49

Assume that category_id is an index key (not primary key) of table books. Is there any difference between the following two SQL statements?

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 07:27

    No, the order of the WHERE clauses does not matter.

    The optimizer reviews the query & determines the best means of getting the data based on indexes and such. Even if there were a covering index on the category_id and author columns - either would satisfy the criteria to use it (assuming there isn't something better).

提交回复
热议问题