概念:没有任何查询条件限制的查询,被称为交叉连接查询。
例如:select * from A cross join B[ cross join ...];(官方写法) 或者 select * from A , B[,C...];
注意:查询出来的结果是笛卡尔积。
2.内连接:inner join on
(1)隐式内连接:就是交叉连接后,可以有where+关联条件。
例如:select * from A,B where A.id = B.id;
(2)显式内连接(常用):就是我们正常用的inner join.. on...
a.等值连接:就是on后面跟的关联条件(A.id = B.id)是“=”。
例如:select * from A [inner] join B on A.id = B.id [and..] where...
b.不等值连接:就是on后面跟的关联条件(A.id != B.id)是“<“或”>”。
例如:select * from A [inner] join B on A.id < B.id [and..] where...
(3)自连接查询:就是在一张表内,存在主外键关系,我们可以看成两张表,使用内连接查询,叫做自连接查询。
例如:select * from A a inner join A a1 on a.id = a1.tid where...
注意:1.我们所说的内连接查询指的就是显式的。
2.当内连接查询没有关联条件的时候和交叉连接一样,查询出的结果都是笛卡尔积。