Inner join INNERJOIN is the most commonly used connection operation. Described in mathematical terms, this sentence can be rewritten as: From the perspective of set theory, we require the intersection of two sets; and from the perspective of Cartesian product, we need to filter out the Cartesian product elements that satisfy the ON condition.
In my opinion, inner joins are similar to equal joins. Natural joins are a special join in inner joins.
What is a natural join?
Natural join (Naturaljoin) is a special equivalent join. It requires that the components to be compared in the two relationships must be the same attribute group, and duplicates are included in the result. The attribute column is removed.
What is an equijoin?
Equijoin is a common connection method of relational operation-join operation. It is a conditional connection (or θ connection) when the connection operator is "=", that is, a special case when θ=0
Example analysis:
Table aaa
Table bbb:
##Query the data with equal attributes C B D in table aaa and table bbbEqual join query:SElect*from aaa,bbb WHERE aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E
-- 自然连接用关键字 natural join SELECT*from aaa natural join bbb;
SElect*from aaa,bbb WHERE aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E
select*from aaa inner join bbb on aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E;
select*from aaa join bbb on aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E;
select*from aaa STRAIGHT_JOIN bbb on aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E;
select*from aaa left join bbb on aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E;
Code implementation:
select*from aaa right join bbb on aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E;
select*from aaa left join bbb on aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E union select*from aaa right join bbb on aaa.C=bbb.C and aaa.D=bbb.D and aaa.E=bbb.E
The above is the detailed content of What is MySQL connection query. For more information, please follow other related articles on the PHP Chinese website!