SQL syntax question
am 19.10.2006 01:54:23 von Tenacious
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');
Re: SQL syntax question
am 19.10.2006 02:53:46 von Bill Karwin
Tenacious wrote:
> 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.