MySQL JOINS不带where子句 [英] MySQL JOINS without where clause

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

问题描述

我知道在MySQL SQL中,仅索引在WHERE子句中使用的那些字段才有意义.但是,如果您使用的是JOINS,我相信JOIN也可以充当WHERE子句,因为它正在比较两个字段.例如:

I know that in MySQL SQL it only makes sense to index those fields you use in the WHERE clause. But if you are using JOINS, i believe that the JOIN also acts as the WHERE clause because it is comparing two fields. For example:

select b.name, p.location 
from Branch as p, Person as p
where b.id = p.id;

select b.name, p.location
from Branch as p
INNER JOIN Person as p ON (p.id = b.id);

所以我的理解是INNER JOIN = WHERE子句以某种方式或通过MySQL进行了翻译,因此可以在其上建立索引,即,对JOIN上使用的列进行了索引(如果在其上创建了索引) .我的理解正确吗?

So my understanding is that the INNER JOIN = WHERE clause in a way, or translated that way by MySQL, and hence can be indexed on i.e, a columns used on a JOIN are indexed (if they have indexes created on them). Is my understanding correct?

推荐答案

其中的位置和Join非常相似.但是,Join在表级别上更多,而在列级别上更多.是的,你是正确的.

Where and Join are pretty similar. However, Join is more at table level, and where is more at column level. Yes, you are corrrect.

这篇关于MySQL JOINS不带where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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