[Lazarus] Zeos Component Join Query
JoshyFun
joshyfun at gmail.com
Tue Jan 12 18:54:49 CET 2010
Hello Lazarus-List,
Tuesday, January 12, 2010, 6:07:37 PM, you wrote:
MF> I got an *sql logic error* trying to execute following query using Zeos
MF> Component (ZQuery):
MF> "SELECT Invoices.*, Customers.Name
MF> FROM Invoices
MF> LEFT JOIN Customers
MF> ON Invoices.CustomerID= Customers.ID
MF> * WHERE Customers.Name = 'Tom' "*
MF> excluding the Where clause make the query run without problems.
From my point of view it is a "SQL logic error", I think it should be:
"SELECT Invoices.*, Customers.Name
FROM Customers
RIGHT JOIN Invoices
ON Invoices.CustomerID= Customers.ID
WHERE Customers.Name = 'Tom' "
Note the swapping of Customers and Invoices, the other way the SQL
engine will sequentially scan all invoices to join them with customer
and perform the "where". Anyway I do not know why ZQuery raises and
exception :-? (I'm not using Zeos at all).
--
Best regards,
JoshyFun
More information about the Lazarus
mailing list