gpt4 book ai didi

SQLITE INNERJOIN 噩梦,需要一个解决方案

转载 作者:行者123 更新时间:2023-12-02 20:08:26 24 4
gpt4 key购买 nike

很高兴找到这样一个有用的网站,里面有天才成员(member)。一段时间以来,我一直在尝试寻找解决此 SQLITE 问题的方法。谷歌没有帮助我,除了找到这个网站。 SQL 查询在同一数据库的 MSAccess 版本上运行良好。

这是我的 SQL 语句 - 它对我不起作用。

<小时/>
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'));
<小时/>

错误消息是:无法编译 Select-Statement:没有这样的列:Invoices.InvoiceNumber

最佳答案

这通常意味着您拼错了列名称...检查您的发票表并确保该列是 InvoiceNumber 而不是“Invoice_Number”或类似的内容...

此外,这个查询的一个更简单的版本看起来像这样..没有所有奇怪的嵌套:

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'

关于SQLITE INNERJOIN 噩梦,需要一个解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2219299/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com