如何写这个查询语句??

Amphibian 2004-10-28 10:39:01
tablea
a
-----
1
2
3
5
tableb
a b c
----------
1 1 1
1 1 2
1 2 3
2 1 2
2 2 3
3 1 1
4 2 3
b表a字段和a表a字段匹配,怎么样从b表选出符合a表a字段的一条记录,只能是一条。
结果肯定是个不固定的,例如有这么一种结果:
1 1 1
2 2 3
3 1 1
...全文
93 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Amphibian 2004-10-28
  • 打赏
  • 举报
回复
多谢,结帖。
bzszp 2004-10-28
  • 打赏
  • 举报
回复
or

select t.* from
(select * from b where rowid in (select min(rowid) from b group by a)) t,a
where a.a=t.a;
bzszp 2004-10-28
  • 打赏
  • 举报
回复

select * from b where rowid in (select min(rowid) from b group by a)
and exists(select 1 from a where a.a=b.a);
Amphibian 2004-10-28
  • 打赏
  • 举报
回复
oracle8i

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧