MySQL联合查询(多表查询)

一、内连接

select *from 表1 [ inner | cross ] join 表2 [ on过滤条件 ] [ where查询条件 ] ;

[ inner | cross ]:

join 内连接关键字(必须要有);

on从语法上可省略,但如果省略它,将查询的是多表的笛卡尔积;

1.select *from 表1 join 表2 [ on过滤条件 ] [ where查询条件 ] ;

2.select *from 表1,表2 [ where查询条件 ] ;

3.select *from 表1 inner join 表2 [ on过滤条件 ] [ where查询条件 ] ;

4.select *from 表1 cross join 表2 [ on过滤条件 ] [ where查询条件 ] ;

(1.2使用较多;多表查询使用1较好)

例1

猜你喜欢

转载自blog.csdn.net/fwdwqdwq/article/details/125157410