【mysql】基础-多表查询(下)

该博客详细讲解了多表查询的各种方法,包括内连接、外连接、自连接、联合查询以及各种子查询的使用,结合具体的表创建语句和查询示例,深入浅出地介绍了MySQL中的多表操作。
摘要由CSDN通过智能技术生成

 上文 中描述了多表关系、内连接、外连接、自连接、联合查询 union, union all、标量子查询、列子查询、行子查询、表子查询

文章链接在【mysql】基础-多表查询(上)_無名_b的博客-CSDN博客

【mysql】基础-多表查询(中)_無名_b的博客-CSDN博客

本文给出了 多表查询 的表创建语句以及多表查询语句的演示

-- ------------------------------------> 多表查询 <--------------------------------------------
-- 准备数据
create table dept(
    id   int auto_increment comment 'ID' primary key,
    name varchar(50) not null comment '部门名称'
)comment '部门表';

create table emp(
    id  int auto_increment comment 'ID' primary key,
    name varchar(50) not null comment '姓名',
    age  int comment '年龄',
    job varchar(20) comment '职位',
    salary int comment '薪资',
    entrydate date comment '入职时间',
    managerid int comment '直属领导ID',
    dept_id int comment '部门ID'
)comment '员工表';

-- 添加外键
alter table emp add constraint fk_emp_dept_id foreign key (dept_id) references 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值