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

  1. #1

    Default Database Menu

    I currently have a page that has a menu section that is populated from a
    database table called category, the categories are for example TVs, DVDs etc,
    the user can select a category and all the products within that category are
    displayed, the client now wishes to change the menu to include the
    manufacturers for each particular category. The manufacturers are in another
    table called manufacturer which is linked to another table called products, I
    have managed to join the tables together but my query returns the manufacturer
    for each product, so I may for example get Sony returned several times, whereas
    I really need the manufacturer that have products within that category to only
    appear once.

    I hope that makes sense.

    <cfquery name="rsProductGroups" datasource="audiovisual">
    SELECT Category.ProductGroup, Category.SidebarGraphic, Category.Ordered,
    Category.CategoryID, Category.Show, Manufacturer.Manufacturer
    FROM Manufacturer INNER JOIN (Category INNER JOIN Products ON
    Category.CategoryID = Products.CategoryID) ON Manufacturer.ManufacturerID =
    Products.ManufacturerID
    WHERE Category.show = true
    ORDER BY Category.Ordered desc, Manufacturer.manufacturer</cfquery>

    pwizzard Guest

  2. Similar Questions and Discussions

    1. flash menu with php/mysql database
      Can anyone point me in the direction of a tutorial. I want to create a flash menu and have that menu populated by accessing a php/mysql database. ...
    2. List Menu and database
      Can some one please tell me in case of multiple selection from the List menu how can i write select statement. Thanks in advance Nike
    3. How do I build Drop Down menu using Menu magic with Database result
      Hi Every One. I resently purched Menu Magic Dropdown System. I would like to list my database content like news( few sentense with link ), Authers...
    4. How can I post contents of a menu to a database?
      Hello all, I've created a web form that will post to an Access database. All of the form fields correctly save to the database upon submit using:...
    5. Create drop down menu for database?
      I have a database of bands and concerts, and was wondering if I could have a drop down menu with the band names, and when one was selected, have...
  3. #2

    Default Re: Database Menu

    <cfquery name="rsProductGroups" datasource="audiovisual">
    SELECT Category.ProductGroup, Category.SidebarGraphic, Category.Ordered,
    Category.CategoryID, Category.Show, Manufacturer.Manufacturer
    FROM Manufacturer INNER JOIN (Category INNER JOIN Products ON
    Category.CategoryID = Products.CategoryID) ON Manufacturer.ManufacturerID =
    Products.ManufacturerID
    WHERE Category.show = true
    ORDER BY Category.Ordered desc, Manufacturer.manufacturer
    GROUP BY Manufacturer.manufacturer
    </cfquery>


    rmorgan Guest

  4. #3

    Default Re: Database Menu

    Tried that and get the following error:

    Message from server: Error Executing Database Query. Syntax error (missing
    operator) in query expression 'Manufacturer.manufacturer GROUP BY
    Manufacturer.manufacturer'.
    The error occurred on line 1.


    pwizzard Guest

  5. #4

    Default Re: Database Menu

    My mistake, group by comes before order by.
    rmorgan Guest

  6. #5

    Default Re: Database Menu

    I also tried that and got this error:

    Message from server: Error Executing Database Query. You tried to execute a
    query that does not include the specified expression 'ProductGroup' as part of
    an aggregate function.
    The error occurred on line 1.


    pwizzard Guest

  7. #6

    Default Re: Database Menu

    Check your where statement in some flavors of sql, 'show' is a reserved word. May need to rename the column.
    rmorgan Guest

  8. #7

    Default Re: Database Menu

    If I actually add all the tables to the GROUP BY Category.ProductGroup,
    Category.SidebarGraphic, Category.Ordered, Category.CategoryID, Category.Show,
    Manufacturer.manufacturer
    it now works??

    Does this make sense

    Thanks for your help, very much appreciated

    pwizzard Guest

  9. #8

    Default Re: Database Menu

    It makes sense because that's how group by clauses work. It probably doesn't
    solve your problem though. Grouping without an aggregate in the select clause
    rarely accomplishes anything.

    cfoutput has a group attribute that would probably be useful in your
    situation. Details are in the cfml reference manual. If you don't have one,
    the internet does.

    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