Results 1 to 8 of 8

Thread: Left Join Headache [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Brisbane - Australia
    Posts
    23

    Left Join Headache [RESOLVED]

    Hi All

    I am using the following Query: (MySQL v4.1.1a)

    SELECT DISTINCT avail_template.staffkey, avail_template.day_no,
    avail_template.details,
    avail_template.is_shift,
    avail_template.start,
    avail_template.finish
    FROM avail_template
    LEFT JOIN rostered_shifts ON
    avail_template.staffkey = rostered_shifts.staffkey and
    adddate('2004-04-16', avail_template.day_no) = rostered_shifts.date
    WHERE (((rostered_shifts.staffkey) Is Null));

    I thought that this would return a result of those records in the avail_template table that no matching record in the rostered_shifts existed where rostered_shifts.staffkey = avail_template.staffkey and rostered_shifts.date = the date calculated in the adddate function... (This I wanted to be a unique date for each day_no in avail_template)

    My problem is that the query is returning all the records from the avail_template table even though there are records that match the staffkey, date combination in the rostered_shifts table.

    I am new at the whole Join thing and have played with various elements within the query for hours now. To no avail. I have called the computer the filthiest names I could imagine, and whispered sweet endearments at the thing and Nuthin...

    Any suggestions before I lose my sanity would be much appreciated.

    Thanks

    Dave
    Last edited by daveshack; Jun 9th, 2004 at 06:32 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width