grouping data from lists

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default grouping data from lists

    I am so sure I did this before but am struggling with it now...any help
    appreciated: I have a list of papers that I need to sort under topical
    categories, some papers go under multiple categories....
    item1 'category1' title 1 item2 'category1','category2' title 2 item3
    'category3',''category4' title 3 item4 ''category4' title 4 Output should
    be: 'category1' title 1 title 2 'category2' title 2 title 3 'category3'
    title 3 'category4' title 4 I input this to the database from a form and so
    these category items are a list. I can't do a loop to insert the category items
    to a separate table because I need to associate them with the primary key of
    the other data that is associated with them in the main content table. If I
    input them all together as a list then when I do a group the list mess gets
    output... <cfoutput query='getWPs' group='category'> #category# <cfoutput> #'
    getWPs.title# </cfoutput> </cfoutput> I am not much on T-SQL but see you can
    parse the list and input the items into another table but then I am back to
    figuring how to get the primary key from the rest of the data that goes into
    the main table.... Any help greatly appreciated...

    jonathan driller Guest

  2. Similar Questions and Discussions

    1. Flex 3 advanced data grid grouping, show info with tree
      Hi, Sorry for strange title, some times hard to sum up in one sentence. I have a database with annotations (notes) on a proof. Each note as a...
    2. Advanced Data Grid Column Grouping
      When using column grouping with the advanced data grid, is it possible to ONLY show the AdvancedDataGridColumnGroup headerText and not have the...
    3. Help grouping chart data
      I have a line chart with each axi defined as follows; x is defined by time, and y is defined by bytes. My issue is the data is coming across for two...
    4. Looping over data with grouping
      I have a database (members) with your standard name, address, state, etc. info. I would like to create an output with grouping by state. (a) Can...
    5. Sorting data in Listbox/Dropdown lists
      hi, i have loaded the listbox with the data from a database using dataset. i am finding difficulty in sorting the data. i am not able to find a...
  3. #2

    Default RE: grouping data from lists

    A little more info would be helpful.

    Your output doesn't make sense to me. It looks like 'Category 2' should only have title 2
    and 'Category 4' should have title 3 and title 4.

    Can you display your lists? It might make what you are looking for more clear.
    Rob Guest

  4. #3

    Default Re: grouping data from lists

    As mentioned in many other threads, storing lists in a single field and
    expecting them to represent separate and discrete data elements is bad. You
    need a DB redesign that includes a many-to-many table which holds the
    relationships among the categories and the titles. Sounds like you need more
    work than just this relationship, but it's necessary. T-SQL doesn't handle
    this 'list in a field' stuff because it's not normalized data. Case closed.
    Now that my soapbox has collapsed under the sheer weight of my tirade, here's
    an approach that should get you a normalized relationship. 1. Create a table,
    tblTitlesCategories, with a primary key, and fields to hold the title foreign
    key and the category foreign key. (You do have primary keys on the Categories
    and Titles tables, right?) 2. Assuming you have tables for the titles and
    categories, issue a SELECT statement: select a.*, b.titlePrimaryKey from items
    a, tblTitles b where b.TitleName = a.Title Spin through this recordset using
    the following pseudocode: For each record: For each category field in the
    record: (CFLOOP on the 'list' from that field) select primarykey from
    Categories where CategoryName = [the current value from CFLOOP Insert into the
    many-to-many table the category key (which you just grabbed) and the title key
    from the main recordset Next item in the Category list Next item in the
    recordset Should do ya. HTH,

    philh 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