[thelist] MySQL query help

Jay Blanchard jay.blanchard at niicommunications.com
Mon Jun 10 06:59:00 CDT 2002


[snip]
> > The query (modified a bit to reflect real column names) returns
> > only two rows out of an expected 5. Any thoughts?
>
> try matching on the other ids
>
>    SELECT Tasks.ID, Tasks.CatID, Tasks.ID
>            , taskcategory.ID, taskcategory.Task
>            , taskstatus.ID, taskstatus.TStatus
>     FROM Tasks, taskcategory, taskstatus
>       WHERE Tasks.CatID = taskcategory.ID
>             AND Tasks.StatusID = taskstatus.ID
>
> rudy
>

Only 1 record is returned with the appropriate fields (out of expected 5) -
any other thoughts?
[/snip]

LEFT OUTER JOIN i.e.

SELECT Tasks.ID, Tasks.CatID, Tasks.ID
       , taskcategory.ID, taskcategory.Task
       , taskstatus.ID, taskstatus.TStatus
FROM Tasks LEFT OUTER JOIN taskcategory
       ON (Tasks.CatID = taskcategory.ID)
   LEFT OUTER JOIN taskstatus
       ON (Tasks.StatusID = taskstatus.ID)

HTH!


Jay






More information about the thelist mailing list