多表查询
多表查询:即多个表关联查询,需要依据多表之间列关系将其连接起来,这种连接方式分为三种:内连接(inner join)、外连接(outer join)及交叉连接(cross join)。
为更好阐述这三种连接的关系,我们采用展示代码的方法进行阐述:
首先在数据库中创建user_info 表:
#user_info表
create table user_info(
id int(2) primary key,
user_name varchar(12) unique,
password varchar(15) not null,
real_name varchar(8) not null,
age int(3)
);
之后创建address表:
#address表
create table address(
id int(2) primary key,
user_id int(2) not null,
real_name varchar(8),
mobile