I'm usually pretty well versed with JOINS, but this is new.
Suppose three tables (classic case of two tables and a third, linker table):
Customer Product Transaction
-------- ------- -----------
ID ID CustomerID
Name Desc ProductID
Cost Date
(Simplistic on purpose, I can't reproduce the actual structure, it's not my code.)
Normally, to get a table of "who bought what when", I'd do this:
SELECT Customer.Name, Product.Desc, Transaction.Date
FROM Product
INNER JOIN Transaction ON Transaction.ProductID = Product.ID
INNER JOIN Customer ON Transaction.CustomerID = Customer.ID
But I've been presented with this:
SELECT Customer.Name, Product.Desc, Transaction.Date
FROM Product
INNER JOIN ( Transaction
INNER JOIN Customer ON Transaction.CustomerID = Customer.ID)
ON Transaction.ProductID = Product.ID
What's this? Just another syntax, or a performance trick?
(It's on SQLServer, FYI, but presumably that could be applied to others...)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…