SQL Efficiency: WHERE IN Subquery vs. JOIN then GROUP

后端 未结 7 1653
予麋鹿
予麋鹿 2021-02-07 09:35

As an example, I want to get the list of all items with certain tags applied to them. I could do either of the following:

SELECT Item.ID, Item.Name
FROM Item
WH         


        
7条回答
  •  遇见更好的自我
    2021-02-07 09:52

    The second one is more efficient in MySQL. MySQL will re-execute the query within the IN statement for every WHERE condition test.

提交回复
热议问题