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。 
  就是一个移出仓库 移入仓库都关联一个表,。查询结果都要显示仓库名。 

解决方案 »

  1.   


    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    估计你这查询有问题
      

  2.   

    表名不知道对不对?类似这样的select a.zz,b.zz from tb t
    join tab a on a.zz=t.col1
    join tab b on b.zz=t.col2
      

  3.   

    有点启示了。
    但是带到自己的项目语句里就有问题了。
    汗。 求助。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' 与查询中所用的表名或别名不匹配。
      

  4.   

    是不是移库单号不是JS_InStoTbl  b里的字段??找找看,应该是哪个字段和表的别名没对应好
      

  5.   

    JS_InStoTbl  ,有原句都能执行,就是不能加上 join  ...on ..那句。。
    请帮忙查下哪错了
      

  6.   

    先看看表B 里面又没有b.Supplyid  b.StoreID  这两个字段吧
      

  7.   

    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=9ok了。。    怎么from后面好像不能跟几个表样。   感觉
      

  8.   

    o,好像是这样的,要么全用join连接
    要么不用join,全放where后面,以逗号分隔