Display names from tbl 2 based on ID's in tbl1

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

  1. #1

    Default Display names from tbl 2 based on ID's in tbl1

    Hi all,

    Silly question I'm sure but it's escaping me at the moment.

    Here's the important parts of 2 tables I have:

    tblCallbacks
    -----------------
    CBID
    CSR1

    tblEmployees
    -----------------
    EmpID
    EmpFirstName

    On my data entry page I have a dropdown box that is populated from
    tblEmployees. It's values are the EmpID's. These values are written into the
    CSR1 field in tblCallbacks.

    Question is...when I want to pull up a list of callbacks from tblCallbacks,
    how do I show the name from tblEmployees instead of the ID in tblCallbacks.CSR1?

    I just can't get the query for some reason....

    Thx!
    Mike

    MikeyJ Guest

  2. Similar Questions and Discussions

    1. Display name based on date
      Hi All, I am trying to put together a cfm page that will display a users name based on the day of the week. The user selects a range of dates that...
    2. ANN: SPi-V, Shockwave based panoramic display engine
      Today I released my Shockwave based panoramic viewing engine. http://fieldofview.nl/press/041122_SPi-V I guess panoramic photography is a bit...
    3. display COM+ process id's in an asp page
      Making a good old fashioned asp page and need to be able to display the IIS COM+ process id's (i.e. those that show up when attaching to a process...
    4. display text field based on the selection choices
      I want to display credit card fields when the user selects the option paid membership. If user selects the option free membership, then the credit...
    5. How to display alternate text based on dynamic data?
      I need to display alternate text based on returns from a record set. For example, when my recordset returns "21," which is a code for an employee...
  3. #2

    Default Re: Display names from tbl 2 based on ID's in tbl1

    select tblcallbacks.cbid, tblemployees.empfirstname
    from
    tblcallbacks JOIN tblemployees ON (tblcallbacks.csr1 = tblemployees.empid)
    Kronin555 Guest

  4. #3

    Default Re: Display names from tbl 2 based on ID's in tbl1

    Wow! Thx for the fast reply! Your solution works like a charm.

    Now, to throw a curveball atcha. ;-)

    I also have a field in tblCallbacks named CSR2. It works the same as CSR1 in
    that it also holds an EmpID. How do I do the same for CSR2? I need to display
    the corresponding names for both CSR1 and CSR2 in the same record.

    Hope I explained well enough.

    Thx again!
    Mike

    MikeyJ Guest

  5. #4

    Default Re: Display names from tbl 2 based on ID's in tbl1

    You may need to add parenthesis to the JOIN statements depending on your
    database....


    SELECT cb.cbid, e1.empfirstname, e2.empfirstname
    FROM tblcallbacks cb JOIN tblemployees e1 ON cb.csr1 = e1.empid
    JOIN tblemployees e2 ON cb.csr2 = e2.empid

    mxstu Guest

  6. #5

    Default Re: Display names from tbl 2 based on ID's in tbl1

    Thanks! This worked perfectly.

    In actuality, both yours and Kronin555's answers were correct and helped me move forward!

    Mike
    MikeyJ 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