Getting data from multiple rows into a list

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Getting data from multiple rows into a list

    I have a table that has values as follows:
    PersonID Degree
    55 MD
    55 Phd
    55 RN
    60 MD
    60 Phd

    I need a create a query that will give me output like this:

    PersonID Degree
    55 MD, Phd, RN
    60 MD, Phd

    Any ideas


    bika_123 Guest

  2. Similar Questions and Discussions

    1. How do I keep a fixed list of rows in a table?
      Probably not making myself clear with that subject. Here is what I want to do. I want to basically implement a FIFO (FirstInFirstOut) queue in...
    2. Multiple rows of data into 1 row
      I have a Pt ID field which is a unique number. I have a S_field which is an ID # that lines to the Pt ID. There are multiple Pt ID's for one...
    3. Update multiple rows data with a single button
      hello I have been trying to run multiple update queries based on the data entered by user. Brief background: I am fetching data from various...
    4. Display 1 data row as multiple datagrid rows
      If a row of data in a dataset has a lot of columns the row displaying the data in a datagrid will run way off the screen. What I'd like to do is...
    5. How would I insert multiple rows of data from one form?
      Dear ASP.NETers, How would I insert multiple rows of data from a web form? Are there any tute's and stuff around. Couldn't find any myself. ...
  3. #2

    Default Re: Getting data from multiple rows into a list

    I would recommend using a cursor, loops and a temporary table. Here's some
    pseudo code:



    Retrieve all PersonIDs
    Loop over each PersonID
    Get all Degrees for PersonID
    Create ListDegree variable
    Loop over each Degree
    Append Degree to the end of ListDegree
    End Degree Loop
    Insert PersonID, ListDegree into a temporary table
    End PersonID Loop
    Select records from temporary table

    SaraGillie Guest

  4. #3

    Default Re: Getting data from multiple rows into a list

    Start with a simple query, ordering by personid. That gets you the output as
    shown in the orginal post. Then do something like this:

    <cfset thisid = 0>
    <cfoutput query="yourquery">
    <cfif personid is not thisid>
    <br>#personid# <cfset thisid = personid>
    </cfif>
    &nbsp; #degree#
    </cfoutput>



    Dan Bracuk 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