[英]Retrieve Data from Table1 using Table2's foreign key and description field
I can't explain it thoroughly in the title, but what I am trying to explain is: I have two tables a table for the assets and a table for the type of assets determined by the AssetCode. 我无法在标题中对其进行详细解释,但是我想解释的是:我有两个表,一个表用于资产,一个表用于由AssetCode确定的资产类型。 In the second table(AssetCode Table), there is the CodeID field, which is related to the AssetCode field in the first table (Assets Table), and the CodeDescription field which indicates the description of the code (eg laptop, chair, printer, etc.). 在第二个表(AssetCode表)中,有一个CodeID字段,它与第一个表(Assets Table)中的AssetCode字段有关,还有一个CodeDescription字段,它指示代码的描述(例如笔记本电脑,椅子,打印机,等等。)。 Is it possible to retrieve the data of the first table using the second table's CodeDescription field? 是否可以使用第二个表的CodeDescription字段检索第一个表的数据?
Try this. 尝试这个。
SELECT
t1.*
FROM
Table1 t1,
Table2 t2
WHERE
t1.AssetCode = t2.CodeID
AND t2.CodeDescription = 'chair';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.