mysql-查询三个表 [英] mysql - query three tables

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

问题描述

我有一个包含三个表的关系数据库.第一个包含ID与第二个包含ID有关.第二个包含与第三个相关的ID.第三个包含我所追求的结果.

I have a relational database with three tables. The first containts id's that relate to the second. The second contains id's that relate to the third. The third contains the results I am after.

是否可以通过单个查询在第一张表中查询一个ID,该ID给出了第三张表中与之相关的所有结果?

Is it possible with a single query to query an id in the first table which gives all results from the third table that relate to it?

对不起,我是mySQL的新手.

Sorry I am new to mySQL.

推荐答案

Mysql加入

尝试一下

select * from table1 t1
join table2 t2 on t1.t2ref = t2.id
join table3 t3 on t2.t3ref = t3.id

添加where子句以搜索table1中的某些行

Add a where clause to search for certain rows in table1

where t1.field = 'value'

这篇关于mysql-查询三个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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