SELECT a.仓库ID,a.仓库名称,d.仓位ID,d.仓位名称,c.内码FROM ( SELECT a.FSTOCKID '仓库ID',b.FNAME '仓库名称'FROM T_BD_STOCK aINNER JOIN T_BD_STOCK_L bON a.FSTOCKID = b.FSTOCKID --仓库列表) aLEFT JOIN ( SELECT FENTRYID '仓位值表FENTRYID',FSTOCKID '仓库ID'FROM dbo.T_BD_STOCKFLEXITEM) bON b.仓库ID = a.仓库IDLEFT JOIN ( SELECT FDETAILID '内码',FENTRYID '仓位值表FENTRYID',FFLEXENTRYID '仓位表FENTRYID'FROM T_BD_STOCKFLEXDETAIL) cON c.仓位值表FENTRYID = b.仓位值表FENTRYIDLEFT JOIN ( SELECT loc.FID AS '仓位ID',locCol1L.FNAME '仓位名称',locCol1.FENTRYID '仓位表FENTRYID'FROM T_BAS_FLEXVALUESDETAIL locLEFT JOIN T_BAS_FLEXVALUESENTRY locCol1ON (loc.FF100004 = locCol1.FENTRYID)LEFT JOIN T_BAS_FLEXVALUESENTRY_L locCol1LON locCol1.FENTRYID = locCol1L.FENTRYID) dON d.仓位表FENTRYID = c.仓位表FENTRYIDWHERE a.仓库名称='备品仓'AND d.仓位名称='B2/01-01-01-001A'
FF100004中的 100004 是仓位值集。
仓位ID就是业务单据上的库位/仓位ID,也是【即时库存】的库位/仓位。