如何限制 Sybase 中的内部连接?
How to limit an inner join in Sybase?
如何限制内部连接或子查询只选择一行?看来我不能在我的 Sybase 版本(Sybase 版本:Adaptive Server Enterprise/15.5/EBF 19902)中的子查询中使用 'top 1'。
示例
select * from A a
inner join B b on a.id = b.Aid
其中 table B 有两条记录链接到 table A(同一个援助)。但我只想加入这些记录中的一个。
我试图用子查询替换内部连接并使用前 1,但这是不允许的。
我在这里找到了解决方案:https://www.periscopedata.com/blog/4-ways-to-join-only-the-first-row-in-sql.html
select * from A a
inner join (select * from B b where b.Aid in (select min(Aid) from B group by Aid) )
as b on b.Aid = a.id
如何限制内部连接或子查询只选择一行?看来我不能在我的 Sybase 版本(Sybase 版本:Adaptive Server Enterprise/15.5/EBF 19902)中的子查询中使用 'top 1'。
示例
select * from A a
inner join B b on a.id = b.Aid
其中 table B 有两条记录链接到 table A(同一个援助)。但我只想加入这些记录中的一个。
我试图用子查询替换内部连接并使用前 1,但这是不允许的。
我在这里找到了解决方案:https://www.periscopedata.com/blog/4-ways-to-join-only-the-first-row-in-sql.html
select * from A a
inner join (select * from B b where b.Aid in (select min(Aid) from B group by Aid) )
as b on b.Aid = a.id