2014-04-28 41 views
1

我已經在本地主機上建立了一個代碼sql代碼(使用XAMPP,phpmyadmin 4.1.6)並且它完美地工作。但是當我上傳使用phpmyadmin 3.5.7的服務器上的所有內容時,代碼無法正常工作。我很確定在本地主機和服務器上都有相同的數據和結構。當我通過phpmyadmin sql查詢在服務器上運行代碼時,#1146錯誤出現,「表'solve.Invoice'不存在」,我相信它存在。這是版本的錯誤嗎?php myadmin 3.5.7#1146表不存在

這裏是SQL代碼:

SELECT Com.CompanyName,IFNULL(SUM(InvIn.total),0) as SumOfTotal, IFNULL(SUM(inc.income),0) as SumOfIncome, IFNULL(SUM(InvIn.total),0)-IFNULL(SUM(inc.income),0) as difference 
FROM companies Com LEFT JOIN 
Invoice Inv ON Inv.CompaniesID=Com.ID JOIN 
InvoiceInput InvIn ON InvIn.InvoiceID=Inv.ID LEFT JOIN 
Income inc ON inc.companyID=com.ID 
GROUP BY Com.CompanyName 
ORDER BY SumofTotal desc 

表發票: http://i.stack.imgur.com/cxDu8.jpg

表企業:

http://i.stack.imgur.com/R1260.jpg

+0

表invoiceinput: http://i.stack.imgur.com/7HpLQ.jpg 表收入: HTTP ://i.stack.imgur.com/8VbeT.jpg – funny

回答

1

我想這是所有關於資本...嘗試這個:

SELECT com.CompanyName, IFNULL(SUM(InvIn.total) , 0) 
AS SumOfTotal, IFNULL(SUM(inc.income) , 0) 
AS SumOfIncome, IFNULL(SUM(InvIn.total) , 0) - IFNULL(SUM(inc.income) , 0) 
AS difference FROM companies com LEFT JOIN invoice Inv ON Inv.CompaniesID = com.ID 
JOIN invoiceinput InvIn 
ON InvIn.InvoiceID = Inv.ID 
LEFT JOIN income inc 
ON inc.companyID = com.ID 
GROUP BY com.CompanyName 
ORDER BY SumOfTotal DESC LIMIT 0 , 30 
1

不要使用COM和COM,例如

FROM companies Com LEFT JOIN 
Income inc ON inc.companyID=com.ID 
相關問題