求SQL

shiyi54321 2007-01-20 02:33:03
由两个表
tab_1
ID T1 T2
1 01 s
2 02 s

tab_2
d1 d2 d3
01 a 北京
03 e 北京
01 b 上海
02 c 上海

查看tab_1时, 想得到如下结果(用tab_2中的d3='上海')
ID T1 T2
1 b s
2 c s

谢谢各位兄弟
...全文
185 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
vokeyliu 2007-01-22
  • 打赏
  • 举报
回复
select a.id,b.d2 t1,a.t2
from tbl1 a
right join
(select * from tbl2
where t2 = '上海'
)b
on a.t1 = b.d2
datacodecat 2007-01-21
  • 打赏
  • 举报
回复
select a.id,b.d2,a.t2
from tab_1 a,
tab_2 b
where a.t1=b.d1
and b.d3='上海'
zealot_001 2007-01-20
  • 打赏
  • 举报
回复
select a.id,b.d2,a.t2
from tab_1 a,tab_2 b
where a.t1=b.d1
and b.d3='上海'
shiyi54321 2007-01-20
  • 打赏
  • 举报
回复
select tab_1.ID,tab_2.d2 T1,tab_1.T2
from tab_1,tab_2
where tab_1.d2(+)='上海' and tab_1.T1(+) =tab_2.d2

选择出的T2列是空的

17,086

社区成员

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

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