Join vs. sub-query

前端 未结 19 2063
广开言路
广开言路 2020-11-21 05:05

I am an old-school MySQL user and have always preferred JOIN over sub-query. But nowadays everyone uses sub-query, and I hate it; I don\'t know why.

19条回答
  •  醉梦人生
    2020-11-21 05:06

    It depends on several factors, including the specific query you're running, the amount of data in your database. Subquery runs the internal queries first and then from the result set again filter out the actual results. Whereas in join runs the and produces the result in one go.

    The best strategy is that you should test both the join solution and the subquery solution to get the optimized solution.

提交回复
热议问题