Ok, I think I'm starting to get it. My intBoutSubCatID field will
sometimes be null because there will not be a value to associate. This
appears to be causing my problem, even using the left join. Any
suggestions anyone? Thank you all for the assistance (and thanks for the
link Jochem, that will come in handy...)

Cutter

Michael T. Tangorre wrote:

> Are you sure the other three tables have related information for each item
> you select in the main item table? If not your "join style" will not produce
> the results you are looking for. If you want results form the BoutItem table
> even if the values are null that relate to the other tables, you need to
> LEFT JOIN (a) the other tables in. If you only want results where there are
> values in the other tables, use INNER JOIN (b).
>
>
> (a)
>
>
> SELECT
>     I.intBoutItemID as ID,
>     I.blActive as Active,
>     S.txtBoutSubCat as SubCat,
>     C.txtBoutCat as Cat,
>     D.txtDesignName as Name,
> FROM
>     tblBoutItem I
>     LEFT JOIN tblBoutSubCat S ON (I.intBoutCatId = S.intBoutCatId)
>     LEFT JOIN tblBoutCat C ON (I.intBoutCatID = C.intBoutCatID)
>     LEFT JOIN tblBoutDesign D ON (I.intBoutDesignId = D.intBoutDesignId)
> ORDER BY
>     D.txtDesignName
>
>
> (b)
>
>
> SELECT
>     I.intBoutItemID as ID,
>     I.blActive as Active,
>     S.txtBoutSubCat as SubCat,
>     C.txtBoutCat as Cat,
>     D.txtDesignName as Name,
> FROM
>     tblBoutItem I
>     INNER JOIN tblBoutSubCat S ON (I.intBoutCatId = S.intBoutCatId)
>     INNER JOIN tblBoutCat C ON (I.intBoutCatID = C.intBoutCatID)
>     INNER JOIN tblBoutDesign D ON (I.intBoutDesignId = D.intBoutDesignId)
> ORDER BY
>     D.txtDesignName
>
> Hope that helps..
>
>
> Mike
>
>
>   _____  
>
> From: Cutter (CF-Talk) [mailto:[EMAIL PROTECTED]
> Sent: Saturday, December 06, 2003 3:29 PM
> To: CF-Talk
> Subject: SOT: SQL question
>
> I have four (4) tables. One table holds IDs that reference info in the
> other three (3) tables by ID. I am trying to pull the information for an
> item, and pull the info specific to that item from the three tables.
> What's wrong with this picture?
>
> select i.intBoutItemID as ID,
> c.txtBoutCat as Cat,
> s.txtBoutSubCat as SubCat,
> d.txtDesignName as Name,
> i.blActive as Active
> from tblBoutItem i,
> tblBoutCat c,
> tblBoutSubCat s,
> tblBoutDesign d
> where c.intBoutCatID = i.intBoutCatID
> and s.intBoutSubCatID = i.intBoutSubCatID
> and d.intBoutDesignID = i.intBoutDesignID
> Order by d.txtDesignName
>   _____
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to