多表查询的问题

startexcel 2004-08-11 06:11:05
表A(调拨单表)
....
targetstockid,sourcestockid
....
targetstockid是目标仓库ID
sourcestockid是源仓库ID
表b(仓库说明表)
ID,NAME
现表A中有如下数据
...,targetstockid,sourcestockid....
1 , 2
怎么写SQL语句能达到如下效果
....TARGETSTOCKNAME,SOURCESTOCKNAME.....
城东仓库, 城北仓库



...全文
118 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zealot_zk 2004-08-12
  • 打赏
  • 举报
回复
select t.name TARGETSTOCKNAME,s.name SOURCESTOCKNAME
from table_a d,table_b t,table_b s
where d.targetstockid=t.id and d.sourcestockid=c.id;
dinya2003 2004-08-12
  • 打赏
  • 举报
回复
select
b.name targetstockname,
c.name sourcestockname
from
tablea a,
tableb b,
tableb c
where
a.targetstockid=b.id
and a.sourcestockid=c.id
daihaidong 2004-08-11
  • 打赏
  • 举报
回复
select b.name as ARGETSTOCKNAME , c.name as SOURCESTOCKNAME
from 表A a , 表b b , 表b c
where a.targetstockid = b.id and a.sourcestockid = c.id
startexcel 2004-08-11
  • 打赏
  • 举报
回复
注:表A的TARGETSTOCKID和SOURCESTOCKID是表B的ID的外键

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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