求关联查询的sql语句

xiaoyuantian 2005-06-01 11:18:40
表1
table1
dm jc
01 你
02 我
03 他

表2
table2
dhhm type1 type2
1 01 02
2 03 01
3 02 03
4 01 02
5 02 01

table2.type1与table1.dm关联
table2.type2与table1.dm关联

现在要查询出
table2 中所有的记录,并且要把type1和type2通过table1换成table1.jc显示
...全文
179 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
辉说慧语 2005-06-06
  • 打赏
  • 举报
回复
关注
bluecocoqd 2005-06-01
  • 打赏
  • 举报
回复
select b.dhhm,a.jc,c.jc from table2 b,table1 a,table1 c
where b.type1 = a.dm
and b.type2 = c.dm
order by dhhm
1 你 我
2 他 你
3 我 他
4 你 我
5 我 你
沝林 2005-06-01
  • 打赏
  • 举报
回复
select b.dhhm,decode(b.type1,a.dm,a.jc) jc1,decode(b.type2,a.dm,a.jc) jc2 from table1 a,table2 b

17,082

社区成员

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

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