怎么把这里面的 移出仓库id 关联成 仓库名

jiangqinggao 2009-08-31 11:04:40
select
b.codeNum as 移库单号,
convert(char(10),b.OptTime,120) as 移库日期,
b.Supplyid as 移出仓库,
d.StoreName as 移入仓库,
a.UniCode as 零件号,
a.UniName as 名称 ,
e.[Size] as 型号,
a.Unit as 单位,
a.Quantity as 数量,
a.price as 单价,
a.amut as 金额
from JS_InListTbl a,JS_InStoTbl b,JS_SupplyTbl c,JS_StoreTbl d,JS_SysItemTbl e
where b.perftype=9 and b.StoreID=d.StoreID and a.unicode =e.UniCode and a.billnum =b.billnum



怎么把这里面的 移出仓库id 关联成 仓库名。其实就是 StoreTbl d 表中的 d.StoreName 名
谢谢 急,不明白的可以加我qq 17286375。
就是一个移出仓库 移入仓库都关联一个表,。查询结果都要显示仓库名。
...全文
89 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
华夏小卒 2009-08-31
  • 打赏
  • 举报
回复
是不是移库单号不是JS_InStoTbl b里的字段??

找找看,应该是哪个字段和表的别名没对应好
jiangqinggao 2009-08-31
  • 打赏
  • 举报
回复
有点启示了。
但是带到自己的项目语句里就有问题了。
汗。 求助。

select
b.codeNum as 移库单号,
convert(char(10),b.OptTime,120) as 移库日期,
f.StoreName as 移出仓库,
m.StoreName as 移入仓库,
a.UniCode as 零件号,
a.UniName as 名称 ,
e.[Size] as 型号,
a.Unit as 单位,
a.Quantity as 数量,
a.price as 单价,
a.amut as 金额
from JS_InListTbl a,JS_InStoTbl b,JS_SupplyTbl c,JS_StoreTbl d,JS_SysItemTbl e
join JS_StoreTbl f on b.Supplyid = f.StoreID
join JS_StoreTbl m on b.StoreID =m.StoreID

where b.perftype=9 and b.StoreID=d.StoreID and a.unicode =e.UniCode and a.billnum =b.billnum



提示错误:
服务器: 消息 107,级别 16,状态 2,行 1
列前缀 'b' 与查询中所用的表名或别名不匹配。
华夏小卒 2009-08-31
  • 打赏
  • 举报
回复
表名不知道对不对?

类似这样的

select a.zz,b.zz from tb t
join tab a on a.zz=t.col1
join tab b on b.zz=t.col2
华夏小卒 2009-08-31
  • 打赏
  • 举报
回复

select
b.codeNum as 移库单号,
convert(char(10),b.OptTime,120) as 移库日期,
f.StoreName as 移出仓库,
d.StoreName as 移入仓库,
a.UniCode as 零件号,
a.UniName as 名称 ,
e.[Size] as 型号,
a.Unit as 单位,
a.Quantity as 数量,
a.price as 单价,
a.amut as 金额
from JS_InListTbl a,JS_InStoTbl b,JS_SupplyTbl c,JS_StoreTbl d,JS_SysItemTbl e
join StoreTbl f on f.StoreName=b.Supplyid
where b.perftype=9 and b.StoreID=d.StoreID and a.unicode =e.UniCode and a.billnum =b.billnum

--try 估计你这查询有问题
华夏小卒 2009-08-31
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 jiangqinggao 的回复:]
select b.codeNum as 移库单号, convert(char(10),b.OptTime,120) as 移库日期, f.StoreName as 移出仓库, m.StoreName as 移入仓库, a.UniCode as 零件号, a.UniName as 名称 , e.[Size] as 型号, a.Unit as 单位, a.Quantity as 数量, a.price as 单价, a.amut as 金额  from JS_InStoTbl b join JS_StoreTbl f on b.Supplyid = f.StoreID join JS_StoreTbl m on b.StoreID  =m.StoreID join JS_InListTbl a on b.billnum=a.billnum join JS_SysItemTbl e on a.unicode =e.UniCode where  b.perftype=9

ok了。。    怎么from后面好像不能跟几个表样。  感觉
[/Quote]
o,好像是这样的,要么全用join连接
要么不用join,全放where后面,以逗号分隔
soft_wsx 2009-08-31
  • 打赏
  • 举报
回复
join/inner join
jiangqinggao 2009-08-31
  • 打赏
  • 举报
回复
select b.codeNum as 移库单号, convert(char(10),b.OptTime,120) as 移库日期, f.StoreName as 移出仓库, m.StoreName as 移入仓库, a.UniCode as 零件号, a.UniName as 名称 , e.[Size] as 型号, a.Unit as 单位, a.Quantity as 数量, a.price as 单价, a.amut as 金额 from JS_InStoTbl b join JS_StoreTbl f on b.Supplyid = f.StoreID join JS_StoreTbl m on b.StoreID =m.StoreID join JS_InListTbl a on b.billnum=a.billnum join JS_SysItemTbl e on a.unicode =e.UniCode where b.perftype=9

ok了。。 怎么from后面好像不能跟几个表样。 感觉
sgliuzhijie 2009-08-31
  • 打赏
  • 举报
回复
先看看表B 里面又没有b.Supplyid b.StoreID 这两个字段吧
jiangqinggao 2009-08-31
  • 打赏
  • 举报
回复
JS_InStoTbl ,有原句都能执行,就是不能加上 join ...on ..那句。。
请帮忙查下哪错了

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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