Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    165

    Unanswered: two FKs to same description table (was "I don't know how to word this title?? :)"

    Here is my situation: We have an "events" table which tracks certain events. We have two columns in there: "chargedID" and "convictedID." The "chargedID" column holds the information for what a client is initially being charged for. The "convictedID" column holds the information for what the client is actually charged for. We have a second table, "events_description" which holds the information describing the "chargedID" and "convictedID" columns. I can query our "events" table to display both the "chargedID" and "convictedID" columns; howerver, I want to include the descriptions of each charge from the "events_description" table. I can only show the correct information for the "chargedID" column but not the descriptions for the "convictedID" column. Does anybody know how to do this? Thanks for any help!

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Question

    Maybe this can help.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select eventID
         , chg.description as charged_descr
         , con.description as convicted_descr
      from events
    inner
      join events_description as chg
        on events.chargedID = chg.eventID
    inner
      join events_description as con
        on events.convictedID = con.eventID
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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