sql内联接外联接三张表_在SQL中联接三个或更多表

sql内联接外联接三张表

Here you will learn about joining three tables in sql with example.

在这里,您将通过示例了解有关在sql中联接三个表的信息。

Let us consider three tables Employee, Department and Project. We will see the complete example wherein these 3 tables are joined to produce a result:

让我们考虑雇员,部门和项目三个表。 我们将看到完整的示例,其中将这3个表连接起来以产生结果:

表员工 (Table Employee)

This table records the Id of the Employee which is the primary key, the name of the working Employee, the Department Id of the Department they are working in and the Project they are working for.

此表记录了作为主键的Employee ID,工作Employee的名称,他们正在工作的部门的部门ID以及他们正在工作的项目。

  • EId – Primary key which holds Id of the Employee.

    EId –保留员工ID的主键。
  • EName – Name of the Employee.

    EName –员工名称。
  • DId – Department Id of the Department, the Employee is working in.

    DId –部门的部门ID,员工正在工作。
  • PId – Project Id of the project the Employee is working for.

    PId –员工正在从事的项目的项目ID。

Table creation:

表创建:

CREATE TABLE Employee(EId int primary key,  EName varchar(20), DId int, PId int)
 
INSERT INTO Employee VALUES(1, Ramesh)
 
INSERT INTO Employee VALUES(2, Somesh)
 
INSERT INTO Employee VALUES(3, Rajesh)
 
INSERT INTO Employee VALUES(4, Ram)
 
INSERT INTO Employee VALUES(5, Ishi)
 
INSERT INTO Employee VALUES(6, Rekha)
 
INSERT INTO Employee VALUES(7,Mukesh)

This table looks like:

该表如下所示:

EId EName DId PId
1 Ramesh
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值