SELECT TOP (200) B.[Identity], A.Name, A_1.Name AS Expr1 FROM B INNER JOIN A ON B.Id2 = A.Id INNER JOIN A AS A_1 ON B.Id1 = A_1.Id
先感谢各位大神帮忙了! 两外键引用同一主键 SQL [解决办法] SELECT * FROM b JOIN A a ON a.Id = b.Id1 JOIN A a2 ON a2.Id = b.Id2 已经差不多了吧 [解决办法] try this,
select top (200) B.[Identity], (select top 1 a1.Name from A a1 where a1.Id=B.Id2) 'Name', (select top 1 a2.Name from A a2 where a2.Id=B.Id1) 'Expr1' from B
[解决办法] select a.*,b.Name,c.Name as Name1 from A as a inner join B as b on a.id1=b.id inner join B as c on a.id2=c.id [解决办法] select * from a,b where a.id=b.id1 or a.id=b.id2 或者 select * from a,b where a.id=b.id1 and a.id=b.id2 具体的要看你的实际需求。 [解决办法]
select a.*,b.name as create_name,c.name as edit_name from tb a left join tbEmployee b inner join a.id1=b.id left join tbEmployee c inner join a.id2=c.id
[解决办法]
有什么欠妥?应该把join 改为left join吧
SELECT * FROM b LEFT JOIN A a ON a.Id = b.Id1 LEFT JOIN A a2 ON a2.Id = b.Id2