联接与子查询 [英] Join vs. sub-query

查看:94
本文介绍了联接与子查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个老式的MySQL用户,并且总是优先使用JOIN而不是子查询.但是如今,每个人都使用子查询,而我讨厌它.我不知道为什么

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.

我缺乏理论判断力来判断自己是否有差异.子查询是否与JOIN一样好,因此不必担心吗?

I lack the theoretical knowledge to judge for myself if there is any difference. Is a sub-query as good as a JOIN and therefore is there nothing to worry about?

推荐答案

来自MySQL手册(

左[OUTER] JOIN可能比同等子查询更快,因为服务器可能能够更好地对其进行优化-这不仅限于MySQL Server.

A LEFT [OUTER] JOIN can be faster than an equivalent subquery because the server might be able to optimize it better—a fact that is not specific to MySQL Server alone.

因此子查询的速度可能比LEFT [OUTER] JOIN慢,但我认为它们的优势是可读性稍高.

So subqueries can be slower than LEFT [OUTER] JOIN, but in my opinion their strength is slightly higher readability.

这篇关于联接与子查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆