[英]How to join two tables in this example
You need a join with multiple instances of table2 您需要具有table2的多个实例的连接
select b.name,c.name
from table1 a inner join table2 b on a.targetid=b.objectid
inner join table2 c on a.assignedid=c.objectid
JOIN the Table2
two times with Table1
and add the proper alias names will solve in your request. 使用Table1
Table2
两次,并在您的请求中添加正确的别名。
The working query is: 工作查询是:
SELECT T2.Name AS ComputerName, T3.Name AS SoftwareName
FROM Table1 T1
JOIN Table2 T2 T2.ObjectId = T1.TargetId
JOIN Table2 T3 T3.ObjectId = T1.AssignedId
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.