Hi.

On Sat 2003-01-25 at 14:25:14 -0400, [EMAIL PROTECTED] wrote:
> On Fri, 2003-01-24 at 20:27, Hoffman, Geoffrey wrote:
[...]
> > It's returning only stories in a section that have photos, 
> > but I need it to return all the stories in a section whether 
> > it has a photo or not.
> > 
> > I think the problem is in the 
> > WHERE evtphoto.phtusage = 1 -- if there's no photo, 
> > then there's no phtusage.
[...]

You simply have to move that condition from the WHERE clause to the
appropriate ON clause (and drop the part you put in to handle the case
without photo):

  SELECT
    evtstorysection.secid,
    [...]
  FROM
    evtstory
    LEFT JOIN evtlayoutsum     ON evtstory.slytid = evtlayoutsum.lytid
    LEFT JOIN evtstorysection  ON evtstory.styid = evtstorysection.styid
    LEFT JOIN evtstoryorder    ON evtstory.styid = evtstoryorder.styid
    LEFT JOIN evtphoto         ON evtstory.styid = evtphoto.styid AND
                                  evtphoto.phtusage = 1
  WHERE
    evtstorysection.secid = 3 AND 
    evtstoryorder.secid = 3 AND
    evtstoryorder.stodate = '2003-01-24' AND
    evtstory.stypubdate <= '2003-01-24' AND
    evtstory.styexpdate > '2003-01-24'
  ORDER BY
    evtstoryorder.stoorder
  

HTH,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to