SQL查询多个表 [英] SQL query multiple tables
本文介绍了SQL查询多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个表,需要选择相关信息,需要一些查询帮助。
I have 2 tables and I need to select the relative information, need some help with the query.
表2 具有 ID
, MaskID
列。
表3 具有 MaskID
, MaskName
,总计
假设我有一个 ID
已经给出,如何选择 ID
, MaskName
,<$ c表格中的$ c>总计?我如何遍历它们?
Assuming that I have an ID
already given, how can I select the ID
, MaskName
, Total
from the tables? How do I traverse though them?
推荐答案
TSQL查询为:
SELECT t2.ID, t3.MaskName, t3.Total
FROM Table2 AS t2 INNER JOIN Table3 AS t3 ON (t2.MaskId = t3.MaskId)
WHERE ID = 123
不确定您遍历它们的意思。
Unsure what you mean by 'traverse' through them.
这篇关于SQL查询多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文