counting similar entries in a DB

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

  1. #1

    Default counting similar entries in a DB

    I have a Dbase that contains film reviews. and I am trying to generate a
    dynamic menu based on the contents of the dbase.

    lets say the fields are, Film and Review.

    so I have some reviews

    Film 1
    Great film

    Film 2
    Not Bad

    Film 3
    hated it

    Film 1
    didn't think much

    Film 1
    Prefer the original

    now, there are five records, but only three films.

    I can easily generate a menu from this by looping round the recordset and
    generating a link for each entry, When the link is clicked the search
    criteria will be for that film and all records relating to that film will be
    displyed. i.e. showreview.asp?film=film1 etc etc. This means I only supply
    links to film reviews that actually exist.

    but I want to make sure that there is only one menu link for Film1 and not
    three.

    How would I go about doing this?

    I could create a new db for each film but I don't think that idea is very
    "streamlined"

    many thanks



    Alistair Guest

  2. Similar Questions and Discussions

    1. Searchin for multiple similar entries.
      Hi, I am looking for double entry in my database. So that, for example, if the name bob was listed more than once I would get the name and the...
    2. Counting Clicks
      Hi all, A customer of mine has an page with a datagridcontrol.. The grid contains a description field of a pdf document and a HyperlinkColumn...
    3. counting down in a for
      Hi all there is probably a much better way of doing all this i am working on the checkResults sub. it should find the pollerAudit log created...
    4. counting number of unique entries under a column
      hi, i am wanting to count the number of unique rows under a certain column. i want to count how many times a page has been accessed. how i plan to...
    5. Counting files
      Hi, I have a list: file1 file2 dir1/file3 dir1/file4 dir1/subdir1/file5 dir2/file6
  3. #2

    Default Re: counting similar entries in a DB

    Never ask for database-related help without telling us what type and version
    of database you are using. More below:
    Alistair wrote:
    > I have a Dbase that contains film reviews. and I am trying to
    > generate a dynamic menu based on the contents of the dbase.
    >
    > lets say the fields are, Film and Review.
    >
    <snip>
    > now, there are five records, but only three films.
    >
    > I can easily generate a menu from this by looping round the recordset
    > and generating a link for each entry, When the link is clicked the
    > search criteria will be for that film and all records relating to
    > that film will be displyed. i.e. showreview.asp?film=film1 etc etc.
    > This means I only supply links to film reviews that actually exist.
    >
    > but I want to make sure that there is only one menu link for Film1
    > and not three.
    >
    > How would I go about doing this?
    Use the DISTINCT keyword in the query that supplies the records for the
    menu. This should be valid in most databases.

    Select DISTINCT Film FROM Films ORDER BY Film
    >
    > I could create a new db for each film but I don't think that idea is
    > very "streamlined"
    Exactly. It would not result in "normalized" database. Your current design
    is fine, unless you are repeating information about each film in each record
    about the film, in which case you might want to break out that information
    into a second "header" table.

    HTH,
    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  4. #3

    Default Re: counting similar entries in a DB

    I know I am pretty new at this stuff, but I am thinking that in his example,
    using distinct may still produce 3 instances of Film, since the record in
    each instance is a little different. Would MS Datashaping be a way to help
    him out here?

    Steve G

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:u0yScgwlDHA.3316@tk2msftngp13.phx.gbl...
    > Never ask for database-related help without telling us what type and
    version
    > of database you are using. More below:
    > Alistair wrote:
    > > I have a Dbase that contains film reviews. and I am trying to
    > > generate a dynamic menu based on the contents of the dbase.
    > >
    > > lets say the fields are, Film and Review.
    > >
    > <snip>
    > > now, there are five records, but only three films.
    > >
    > > I can easily generate a menu from this by looping round the recordset
    > > and generating a link for each entry, When the link is clicked the
    > > search criteria will be for that film and all records relating to
    > > that film will be displyed. i.e. showreview.asp?film=film1 etc etc.
    > > This means I only supply links to film reviews that actually exist.
    > >
    > > but I want to make sure that there is only one menu link for Film1
    > > and not three.
    > >
    > > How would I go about doing this?
    >
    > Use the DISTINCT keyword in the query that supplies the records for the
    > menu. This should be valid in most databases.
    >
    > Select DISTINCT Film FROM Films ORDER BY Film
    >
    > >
    > > I could create a new db for each film but I don't think that idea is
    > > very "streamlined"
    >
    > Exactly. It would not result in "normalized" database. Your current
    design
    > is fine, unless you are repeating information about each film in each
    record
    > about the film, in which case you might want to break out that information
    > into a second "header" table.
    >
    > HTH,
    > Bob Barrows
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Steve G Guest

  5. #4

    Default Re: counting similar entries in a DB

    Steve G wrote:
    > I know I am pretty new at this stuff, but I am thinking that in his
    > example, using distinct may still produce 3 instances of Film, since
    > the record in each instance is a little different.
    No. Try it with a table in your database.

    It would only produce multiple records for each Film if you included both
    fields (Film and Review) in the select statement. Since my suggested Select
    statement only includes the Film column, the query will only return 1 record
    for each unique Film. I am assuming that the content of the Film column is
    unique for each film. If not, then he has other problems.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  6. #5

    Default Re: counting similar entries in a DB

    Quite right...sorry, I misread his post. Thought he was trying to pull both
    the film name and the review at the same time.

    Steve G

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OXLjInxlDHA.2616@TK2MSFTNGP11.phx.gbl...
    > Steve G wrote:
    > > I know I am pretty new at this stuff, but I am thinking that in his
    > > example, using distinct may still produce 3 instances of Film, since
    > > the record in each instance is a little different.
    >
    > No. Try it with a table in your database.
    >
    > It would only produce multiple records for each Film if you included both
    > fields (Film and Review) in the select statement. Since my suggested
    Select
    > statement only includes the Film column, the query will only return 1
    record
    > for each unique Film. I am assuming that the content of the Film column is
    > unique for each film. If not, then he has other problems.
    >
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Steve G 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