SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot soart's Avatar
    Join Date
    Nov 2003
    Location
    Norwich UK
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Join statements again!

    This is the relevant join code
    PHP Code:
       $results = @mysql_query('SELECT images.* FROM images LEFT OUTER JOIN works ON images.id = works.imageid LEFT OUTER JOIN artist on images.id = artist.bioimage WHERE works.imageid is NULL and artist.bioimage is NULL order by images.filename'); 
    I have an additional field in the images table called reference which is NULL if no data so what I would like to do is include in the WHERE section

    and images.reference is NULL but that kills the statement and gives zero return....any ideas on how to use it as

    PHP Code:
       $results = @mysql_query('SELECT images.* FROM images LEFT OUTER JOIN works ON images.id = works.imageid LEFT OUTER JOIN artist on images.id = artist.bioimage WHERE works.imageid is NULL and artist.bioimage is NULL and images.reference is NULL order by images.filename'); 
    Cheers

    Alternatively I'd be quite happy to just have images.reference != ""

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Hmmm, looks like it should work to me. Are you sure you've got NULL values in the images table?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •