1.简单介绍一下多表联查的概念
当要查询的数据在多张表时,使用多表联查
2.多表联查的分类
MySQL联合查询
交叉联合查询 cross join
内连接联合查询 inner join (MySQL简写join)
外连接联合查询: 左外连接联合查询 left outer join (MySQL简写left join)
右外连接联合查询 right outer join (MySQL简写right join)
3.创建两张表
create table table1(
customer_id varchar(20) not null,
city varchar(20) not null,
primary key(customer_id)
) default charset = utf8
#----------------------------------------------------------------
create table table2(
order_id int not null auto_increment,
customer_id varchar(20),
primary key(order_id)
)default charset = utf8
#-----------------------------------------------------------------------
insert into table1(customer_id,city) values
('tedu','hangzhou'),('jd','shanghai'),('tx','hangzhou'),('baidu','hangzhou')
insert