Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    15

    Unanswered: Joining tables with possible null foreign key

    Howdy,

    I'm running a report (using CR8.5) that shows daily activities of our employees from our DAILY table. The DAILY entries have a foreign key to our FACILITY table, which is sometimes null . I'd like to show all the daily entries with some facility info from those associated with a facility, but as soon as I link DAILY to FACILITY, my report loses all entries with a null in the DAILY."FACILITY_ID" field.

    Is there someway I can straighten this out within CR?

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You can if CR handles left joins, which it should.

    select *
    from DAILY
    left outer join FACILITY on DAILY.KEYFIELD = FACILITY.KEYFIELD

    This shows all records from DAILY regardless of whether a matching record exists in FACILITY.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Mar 2004
    Posts
    15
    Thanks, that did the trick!

Posting Permissions

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