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


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to