Query with Header & Detail

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Query with Header & Detail

    Here's my tables:
    [ServiceCategory]
    [ServiceCatID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    [ServiceCategory] [char] (50) NULL ,

    [Services]
    [ServiceID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    [ServiceCatID] [int] NULL ,
    [ServiceName] [char] (100) NULL ,
    [ServicePrice] [money] NULL ,

    [ServiceDetails]
    [ServiceDetailID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    [Detail] [char] (50) NULL ,

    [ServiceDetailJoin]
    [ServiceID] [int] NOT NULL (PRIMARY KEY)
    [ServiceDetailID] [int] NOT NULL (PRIMARY KEY)

    I want to show all of this in a single table. I have ServiceCategory and
    ServiceName, ServicePrice coming across in a single query and displayed in a
    single table. I have a variable keeping track of Service Name and only
    printing it(within it's own table row) when it changes.
    Here's a copy of the output, although it's kind of ugly.

    Oil Service (ServiceCategory)
    Oil Change Service $26.95
    Premier Oil Change Service with BG MOA Package (Price does not include
    synthetic oil) $32.95
    Transmission Service (ServiceCategory)
    Complete System Power Flush with BG Flush ATC Package
    $149.95
    Upper Induction Service (ServiceCategory)
    All with BG Cleaning Packages without EGR $189.00
    Throttle Plate Cleaning $78.90
    Induction Service, 3 Part $109.95

    Here's the problem, some of these Services have ServiceDetails.Details.
    Besides the fact that I'm still having problems with my query as it's part
    of a Many to Many junction table, there's is going to have to be several
    mores variables to track and only print when changed.

    My other option is to change the Query and rehit the database for each
    detail line(Maybe 20 seperate Recordset and database hits per page)

    Which is the best method?


    Chris White Guest

  2. Similar Questions and Discussions

    1. Query regarding Soap Header
      Hi all, I have a problem on hand. I am developing a Soap Client in VB.Net and Soap Header of the WSDL of the web service to be consumed (which has...
    2. How to do a basic header detail with two grids in a client side call?
      I am interested in having a grid with header items and a second grid with detail items. I was wondering if possible and how to do it if it is, to...
    3. Can I delete from the detail of a master/detail datagrid?
      Hi Mark, As for the delte certain items in the detailed grid items in MASTER/DETAIL grids. Here are my suggestions; The DataGrid, DataList or...
    4. Header Detail Example
      I want to relate 2 tables in Access or SQL for a one to many. I would like to find an example in .Net for data entry for this structure. For...
    5. Master Detail detail
      Dear gurus, I have got a scenario where I have a master table its detail table its detail table. How to implement this using Data Grid or is...
  3. #2

    Default Re: Query with Header & Detail

    The best way is to hit the database once, and return all the info you need.

    Then, in your presentation layer code (ASP, PHP, whatever), you use some
    conditional logic to work out when to display headers and details

    cheers
    Ken

    "Chris White" <nothanks.com> wrote in message
    news:eU2dr74cEHA.1424@tk2msftngp13.phx.gbl...
    > Here's my tables:
    > [ServiceCategory]
    > [ServiceCatID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    > [ServiceCategory] [char] (50) NULL ,
    >
    > [Services]
    > [ServiceID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    > [ServiceCatID] [int] NULL ,
    > [ServiceName] [char] (100) NULL ,
    > [ServicePrice] [money] NULL ,
    >
    > [ServiceDetails]
    > [ServiceDetailID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    > [Detail] [char] (50) NULL ,
    >
    > [ServiceDetailJoin]
    > [ServiceID] [int] NOT NULL (PRIMARY KEY)
    > [ServiceDetailID] [int] NOT NULL (PRIMARY KEY)
    >
    > I want to show all of this in a single table. I have ServiceCategory and
    > ServiceName, ServicePrice coming across in a single query and displayed in
    a
    > single table. I have a variable keeping track of Service Name and only
    > printing it(within it's own table row) when it changes.
    > Here's a copy of the output, although it's kind of ugly.
    >
    > Oil Service (ServiceCategory)
    > Oil Change Service $26.95
    > Premier Oil Change Service with BG MOA Package (Price does not include
    > synthetic oil) $32.95
    > Transmission Service (ServiceCategory)
    > Complete System Power Flush with BG Flush ATC Package
    > $149.95
    > Upper Induction Service (ServiceCategory)
    > All with BG Cleaning Packages without EGR $189.00
    > Throttle Plate Cleaning $78.90
    > Induction Service, 3 Part $109.95
    >
    > Here's the problem, some of these Services have ServiceDetails.Details.
    > Besides the fact that I'm still having problems with my query as it's part
    > of a Many to Many junction table, there's is going to have to be several
    > mores variables to track and only print when changed.
    >
    > My other option is to change the Query and rehit the database for each
    > detail line(Maybe 20 seperate Recordset and database hits per page)
    >
    > Which is the best method?
    >
    >

    Ken Schaefer Guest

  4. #3

    Default Re: Query with Header & Detail

    [url]http://www.aspfaq.com/2241[/url]

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)




    "Chris White" <nothanks.com> wrote in message
    news:eU2dr74cEHA.1424@tk2msftngp13.phx.gbl...
    > Here's my tables:
    > [ServiceCategory]
    > [ServiceCatID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    > [ServiceCategory] [char] (50) NULL ,
    >
    > [Services]
    > [ServiceID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    > [ServiceCatID] [int] NULL ,
    > [ServiceName] [char] (100) NULL ,
    > [ServicePrice] [money] NULL ,
    >
    > [ServiceDetails]
    > [ServiceDetailID] [int] IDENTITY (1, 1) NOT NULL (PRIMARY KEY)
    > [Detail] [char] (50) NULL ,
    >
    > [ServiceDetailJoin]
    > [ServiceID] [int] NOT NULL (PRIMARY KEY)
    > [ServiceDetailID] [int] NOT NULL (PRIMARY KEY)
    >
    > I want to show all of this in a single table. I have ServiceCategory and
    > ServiceName, ServicePrice coming across in a single query and displayed in
    a
    > single table. I have a variable keeping track of Service Name and only
    > printing it(within it's own table row) when it changes.
    > Here's a copy of the output, although it's kind of ugly.
    >
    > Oil Service (ServiceCategory)
    > Oil Change Service $26.95
    > Premier Oil Change Service with BG MOA Package (Price does not include
    > synthetic oil) $32.95
    > Transmission Service (ServiceCategory)
    > Complete System Power Flush with BG Flush ATC Package
    > $149.95
    > Upper Induction Service (ServiceCategory)
    > All with BG Cleaning Packages without EGR $189.00
    > Throttle Plate Cleaning $78.90
    > Induction Service, 3 Part $109.95
    >
    > Here's the problem, some of these Services have ServiceDetails.Details.
    > Besides the fact that I'm still having problems with my query as it's part
    > of a Many to Many junction table, there's is going to have to be several
    > mores variables to track and only print when changed.
    >
    > My other option is to change the Query and rehit the database for each
    > detail line(Maybe 20 seperate Recordset and database hits per page)
    >
    > Which is the best method?
    >
    >

    Aaron [SQL Server MVP] 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