Displaying Foreign Key data

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Displaying Foreign Key data

    I have a table in a database that refers to both string data and foreign key
    IDs. When I request information from the table, how do I display the text
    instead of the foreign key using Coldfusion?

    Example
    Work_Order Table
    workorderID - 1
    workorderName - need help
    staffFirstName - 1
    staffLastName - 2

    Staff_Name Table
    staffnameID - 1
    staffFirstName - John
    staffLastName - Doe

    Silentking Guest

  2. Similar Questions and Discussions

    1. cfgrid not displaying data
      Ask your host to check the CFIDE mapping. I had a similar issue. It should be mapped by default, but sometimes it is not. Hope that helps!
    2. mx7 cfchart not displaying data
      i have a mx7 cfchart in flash format that has been displaying fine for about a month. Today there are no bars being displayed. the chart is quite...
    3. help displaying data
      I have a products table that which has 'Product_abbrev', 'SubType' and 'Product'. There is a value for all except 'SubType' - some products are...
    4. REPOST: How do you display the data associated with a foreign key?
      Add a calculation field to the UNITS database that equals the value you want from the CATEGORIES database (via the relationship). Something like...
    5. How do you display the data associated with a foreign key?
      Hello: I am using Filemaker Pro 6.0 and trying to reference a foreign key using a drop down box. I have two tables: One is called CATEGORIES and...
  3. #2

    Default Re: Displaying Foreign Key data

    depends somewhat on the db you're using but maybe something like this:

    SELECT w.workorderID,w.workorderName,s.staffFirstName,s.s taffLastName
    FROM Work_Order w
    INNER JOIN Staff_Name s ON w.staffNameID = s.staffNameID
    ORDER BY w.workorderID

    ---or---

    SELECT w.workorderID,w.workorderName,s.staffFirstName,s.s taffLastName
    FROM Work_Order w, Staff_Name s
    WHERE w.staffNameID = s.staffNameID
    ORDER BY w.workorderID

    PaulH Guest

  4. #3

    Default Re: Displaying Foreign Key data

    The database that I am using is MySQL ver 4.0.18
    Silentking Guest

  5. #4

    Default Re: Displaying Foreign Key data

    Maybe we are confused at what I am trying to accomplish so let me start over.

    I have 3 tables at the moment. work_order, staff_name, site_name.

    In my work_order table are the following fields.

    workOrderID
    workOrderName
    siteNameID - from site table
    staffNameID - from staff table
    hardwareType
    softwareType
    etc

    What is important is the siteNameID and staffNameID from the other tables.
    When I do a search for a work order at the moment I do a Select * FROM
    work_order; to get information from the work_order table. The information looks
    similar to this

    workorderID: 9
    workOrderName: PC is broken
    siteNameID: 9
    staffNameID: 5
    hardwareType: PC
    softwareType: n/a

    For the staffNameID and siteNameID parts of the query instead of displaying
    the exact number that references the siteNameID or staffNameID, I would like to
    replace it with the corresponding siteName from the site_name table, and the
    corresponding staffFirstName and staffLastName from the staff_name table. So
    when I perform a query on from the my work_order application it displays the
    information like this:

    workorderID: 9
    workOrderName: PC is broken
    siteNameID: Some Site
    staffNameID: John Doe
    hardwareType: PC
    softwareType: n/a

    I want the query to say look in the site_name table and find siteNameID that
    is equal to 9, and give me the siteName out of Some Site instead of 9 which is
    does now.

    I hope this doesn't confuse you.

    Silentking Guest

  6. #5

    Default Re: Displaying Foreign Key data

    But believe it or not I may have stumbled upon a temporary solution.
    Silentking Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139