开发者

SQLITE INNERJOIN Nightmare, need a solution to this

开发者 https://www.devze.com 2022-12-19 05:50 出处:网络
It\'s nice to find such a useful site with genius members. I have been trying to find a solution for this SQLITE problem for a while now. Google didn\'t help me, except in finding this website. The SQ

It's nice to find such a useful site with genius members. I have been trying to find a solution for this SQLITE problem for a while now. Google didn't help me, except in finding this website. The SQL query works fine on the MSAccess version of the same database.

Here's my SQ开发者_运维百科L statement - which didn't work for me.


SELECT Invoices.InvoiceNumber, Invoices.Quantity,Invoices.Code, Invoices.Price,Invoices.Discount, Invoices.InvoiceGrandTotal, Employees.EmployeeName, Customers.CustomerName, Invoices.DateOfInvoice, [price]*[Quantity] AS Total, Customers.Address, Products.Description,Products.Unit  
    FROM Products 
        INNER JOIN (
            (   
                ( Invoices INNER JOIN InvoiceDetails 
                    ON Invoices.InvoiceNumber = InvoiceDetails.InvoiceNumber
                ) INNER JOIN Customers 
                    ON Invoices.CustomerID = Customers.CustomerID
            ) INNER JOIN Employees 
                ON Invoices.UserID = Employees.EmployeeID
        ) ON Products.Code = InvoiceDetails.Code  
    WHERE (((InvoiceDetails.InvoiceNumber)='10111'));

The error message is: "Cannot compile Select-Statement: no such column: Invoices.InvoiceNumber"


That usually just means that you mis-spelled the column name ... check your Invoices table and make sure the column is InvoiceNumber and not "Invoice_Number" or something similar ...

Also, a much simpler version of this query would look something like this .. without all the strange nesting:

SELECT 
   Invoices.InvoiceNumber, 
   Invoices.Quantity,
   Invoices.Code, 
   Invoices.Price,
   Invoices.Discount, 
   Invoices.InvoiceGrandTotal, 
   Employees.EmployeeName, 
   Customers.CustomerName, 
   Invoices.DateOfInvoice, 
   [price]*[Quantity] AS Total, 
   Customers.Address, 
   Products.Description,
   Products.Unit 
FROM
   Invoices

   JOIN Employees 
      ON Employees.EmployeeID = Invoices.UserID 

   JOIN Customers 
      ON Customers.CustomerID = Invoices.CustomerID

   JOIN InvoiceDetails 
      ON InvoiceDetails.InvoiceNumber = Invoices.InvoiceNumber

   JOIN Products
      ON Products.Code = InvoiceDetails.Code

WHERE 
   InvoiceDetails.InvoiceNumber = '10111'


I think the issue might be with case sensitivity. Unless I'm mistaken, MS Access field names are not case sensitive. Check the offending column name for the correct casing in you SQLITE table definition.

0

精彩评论

暂无评论...
验证码 换一张
取 消