Add Redundant Conditions to Joins






Add Redundant Conditions to Joins

Sometimes, joins can be accelerated easily by adding an extra condition to the WHERE clause, which does not change the end result.

10. Get the payment number and name of the player for all penalties incurred for player 44.

SELECT   PAYMENTNO, NAME
FROM     PENALTIES AS PEN, PLAYERS AS P
WHERE    PEN.PLAYERNO = P.PLAYERNO
AND      PEN.PLAYERNO = 44

Sometimes, SQL can develop a more efficient processing strategy if the condition is extended with a redundant condition, as shown earlier. Obviously, the result of the statement does not change.

SELECT   PAYMENTNO, NAME
FROM     PENALTIES AS PEN, PLAYERS AS P
WHERE    PEN.PLAYERNO = P.PLAYERNO
AND      PEN.PLAYERNO = 44
AND      P.PLAYERNO = 44



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows