|
Posted by Andy Hassall on 08/29/05 17:42
On Mon, 29 Aug 2005 15:18:31 +0200, Gosiek <gosiekg2@o2.pl> wrote:
>I want to select employees and products which they bought. I did it in
>two ways:
>
>SELECT Employees.Name, Orders.Product
>FROM Employees, Orders
>WHERE Employees.Employee_id=Orders.Employee_id
>
>SELECT Employees.Name, Orders.Product
>FROM Employees
>INNER JOIN Orders
>ON Employees.Employee_id=Orders.Employee_id
>
>My question is: which way is faster?
It depends.
The two statements are semantically identical. So, it would seem reasonable
that databases would execute them identically, so neither's any faster, in
theory anyway.
What makes you think one should be faster? And what happened on your database
when you tried it?
The ANSI-style join format using the ON clause (the second one above) is IMHO
far more maintainable - not much of an issue at this point, but when you have
multiple joins, the grouping of join predicates and separation from filter
(WHERE clause) predicates can make it easier to follow the logic.
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Navigation:
[Reply to this message]
|