[英]SQL Server : two columns with the same row values in the same table
您应该使用自我联接(由于表的尺寸,您可能需要在val和ecr上使用适当的分隔索引)
select a.*, b.*
from tableTest as a
inner join tableTest as b
on a.val = b.ecr
如果您不希望内部联接的完整输出,则可以使用如下所示的内容:
select *
from tableTest as t
where exists (
select 1
from tableTest as i
where t.val = i.ecr
)
除了联接之外,另一个选项是子查询:
SELECT *
FROM tableTest
WHERE val IN (SELECT ecr FROM tableTest)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.