MySQL JOINS without where clause

拜拜、爱过 提交于 2019-12-25 15:16:50

问题


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;

is the same as

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

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?


回答1:


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



来源:https://stackoverflow.com/questions/25906085/mysql-joins-without-where-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!