If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > two FKs to same description table (was "I don't know how to word this title?? :)"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-24-05, 12:37
bla4free bla4free is offline
Registered User
 
Join Date: Jan 2005
Posts: 165
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!
Reply With Quote
  #2 (permalink)  
Old 02-24-05, 13:12
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Question

Maybe this can help.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 02-24-05, 13:38
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On