如何在三个表上使用join [英] How to use join on three tables

查看:111
本文介绍了如何在三个表上使用join的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三张桌子

Table1 Table2 和 Table3.

Table1 Table2 and Table3.

具有列 ID 的表 1.具有列名称 ID、名称的表 2.表三有列名Name.

Table1 having column ID. Table2 having column names ID,Name. Table three having column name Name.

现在我想从表 2 中的表 1 中检索 ID,以便与表中的 ID 关联的名称应该在表 3 中.

Now i want to retrive ID from table1 which is there in Table2 by so that the name associated with ID in table to should be in Table3.

Table1.ID=Table2.ID(Table2.Name=Table3.Namw).

Table1.ID=Table2.ID(Table2.Name=Table3.Namw).

不使用 IN 运算符.仅连接.

推荐答案

select table1.id, table2.name
from table1
join table2 on table2.id = table1.id
join table3 on table3.name = table2.name

这篇关于如何在三个表上使用join的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆