List:General Discussion« Previous MessageNext Message »
From:Roger Baklund Date:December 13 2004 4:48pm
Subject:Re: Strange results - Part 2
View as plain text  
Steve Grosz wrote:
> This is a follow up message to a earlier threat this week (which is included
> in the message below)

> "model","CREATE TABLE `model` (
>   PRIMARY KEY  (`PID`)

> "vendor","CREATE TABLE `vendor` (
>   PRIMARY KEY  (`PID`)

> "specs","CREATE TABLE `specs` (
>   PRIMARY KEY  (`SpecID`)

Like Rhino suggested, you are joining on something other than your 
primary keys. Your query, slightly re-arranged for readability:

select *
   from vendor
   left outer join model on
     vendor.PID=model.VendorID
   left outer join specs on
     model.Model=specs.ProdModel
   where
     vendor.Vendor='#URL.Vendor#'

You are joining the model table on vendor.PID=model.VendorID, and 
model.VendorID is not a primary or unique key, it could contain 
duplicates. You are joining the specs table on 
model.Model=specs.ProdModel, neither is a primary key or unique, both 
could containt duplicates.

-- 
Roger

Thread
Strange results - Part 2Steve Grosz13 Dec
  • Re: Strange results - Part 2Roger Baklund13 Dec
    • Re: Strange results - Part 2Roger Baklund13 Dec