2015-04-08 138 views
-1
SELECT itemID AS broID, 
     ittCode AS broField1, 
     ittDescr AS broField2, 
     itemCode AS broField3, 
     itemDesc AS broField4, 
     Qty AS broField5 
FROM tblItem 
     INNER JOIN tblItemType ON (tblItem.itemiitID = tblItemType.ittID AND tblItem.itemProduct = true) 
     LEFT JOIN 
      (SELECT whiitemID, 
        Sum(whiQty) AS Qty 
       FROM tblWarehouseItem AS WI 
        INNER JOIN tblWarehouse AS W ON WI.whiwrhID = W.wrhID 
      WHERE w.wrhTemp = False   
       AND W.wrhActive = True  
       AND w.wrhLock = False  
      GROUP BY whiitemID) AS WItem ON tblItem.itemID = WItem.whiitemID 
ORDER BY ittCode, itemCode 

當我嘗試運行它我得到一個語法錯誤,如果你請幫我 enter image description here語法錯誤在查詢

回答

1

嘗試改變

INNER JOIN tblItemType ON (tblItem.itemiitID = tblItemType.ittID AND tblItem.itemProduct = true) 

INNER JOIN tblItemType ON tblItem.itemiitID = tblItemType.ittID AND tblItem.itemProduct = true 
+0

如果我拆分我的查詢並單獨運行它們,它們工作正常。 – emilios

+0

那不是這樣的感謝 – emilios

+0

你能寫你在stirng中創建sql的方式嗎? @emilios –

1

謝謝我解決它改變上面的行

(tblItem INNER JOIN tblItemType ON (tblItem.itemiitID = tblItemType.ittID AND tblItem.itemProduct = true))