select a.jrnno ,.. , b.scvxh ... from a left join b on b.jrnno = a.jrnno where a表的条件jrnno 主键查出一个 就可以了 我估计你是这个意思 你也可以 用 b left join a 关键是你想要什么结果
select a.jrnno , a.jycode , m.scvbrno , m.scvamt from a , (select t.* from b t where scvamt = (select max(scvamt) from b where jrnno = t.jrnno)) m where a.jrnno = m.jrnno
楼主 是不是想 保证 表A或表B 的记录完整?
那样还有点意思!
a表对应b的多条的啊?这样操作会出现a中记录出现表c的三条了
from a
left join b on b.jrnno = a.jrnno
where a表的条件jrnno 主键查出一个 就可以了
我估计你是这个意思
你也可以 用 b left join a
关键是你想要什么结果
(select t.* from b t where scvamt = (select max(scvamt) from b where jrnno = t.jrnno)) m where a.jrnno = m.jrnno