Connecting Tech Pros Worldwide Forums | Help | Site Map

SQL syntax question

Tenacious
Guest
 
Posts: n/a
#1: Oct 19 '06
This SQL statement returns the same result twice even though there is
only one matching entry in the first table "tbl_Drivers" and none in
the second table. Can anyone explain why? I would appreciate it very
much. I am trying to improve my understanding of SQL.

SELECT * FROM tbl_Drivers Drvs, tbl_Del_Drivers DelDrvs where
(Drvs.FName = 'Larry' AND Drvs.LName = 'Smith') OR (DelDrvs.FName =
'Larry' AND DelDrvs.LName = 'Smith');


Bill Karwin
Guest
 
Posts: n/a
#2: Oct 19 '06

re: SQL syntax question


Tenacious wrote:
Quote:
This SQL statement returns the same result twice even though there is
only one matching entry in the first table "tbl_Drivers" and none in
the second table. Can anyone explain why? I would appreciate it very
much. I am trying to improve my understanding of SQL.
>
SELECT * FROM tbl_Drivers Drvs, tbl_Del_Drivers DelDrvs where
(Drvs.FName = 'Larry' AND Drvs.LName = 'Smith') OR (DelDrvs.FName =
'Larry' AND DelDrvs.LName = 'Smith');
Since you have given no conditions relating the two table, it's a "cross
join". See http://en.wikipedia.org/wiki/Cross_join#Cross_join

Regards,
Bill K.
Closed Thread


Similar MySQL Database bytes