Duplicates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dejan

    #1

    Duplicates

    Hi

    First sorry for my terreble english

    I have mysql table like this:

    id | name
    ---------------------
    1 | Ivan
    2 | John
    3 | John

    Now i wanna display it on web page like this

    Ivan (1)
    John (2)

    Selecting duplicates, buth only showing number of duplicates..
    How to do that?
    tnx in advance
    Dejan



  • Arjen

    #2
    Re: Duplicates

    Dejan wrote:[color=blue]
    > Hi
    >
    > First sorry for my terreble english
    >
    > I have mysql table like this:
    >
    > id | name
    > ---------------------
    > 1 | Ivan
    > 2 | John
    > 3 | John
    >
    > Now i wanna display it on web page like this
    >
    > Ivan (1)
    > John (2)
    >
    > Selecting duplicates, buth only showing number of duplicates..[/color]

    SELECT COUNT (id) GROUP BY name

    Arjen

    Comment

    • Arjen

      #3
      Re: Duplicates

      Arjen wrote:
      [color=blue]
      >
      > SELECT COUNT (id) GROUP BY name[/color]

      Ehmm .... SELECT name, COUNT (id) FROM table ORDER BY name

      Comment

      • Jerry Stuckle

        #4
        Re: Duplicates

        Arjen wrote:[color=blue]
        > Arjen wrote:
        >[color=green]
        >>
        >> SELECT COUNT (id) GROUP BY name[/color]
        >
        >
        > Ehmm .... SELECT name, COUNT (id) FROM table ORDER BY name[/color]


        SELECT name, COUNT(id) FROM table GROUP BY name

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Dejan

          #5
          Re: Duplicates

          How cann i display now name and count number in this code?

          print "<table cellspacing=0 border=1 width=\"25%\" class=\"redovi\ ">\n";
          print "<tr class=\"headlin e\"><td> Grad </td></tr>";
          while ($qry = mysql_fetch_arr ay($result)) {
          print "<tr><td><a href=\"" . "prikaz_jednoga .php?id=$qry[id]\"[color=blue]
          >$qry[id]</a></td>";[/color]
          print "</tr>\n";
          }
          print "</table>\n";


          Jerry Stuckle <jstucklex@attg lobal.net> wrote in message
          news:P4GdnYD8Gs 3boqPZnZ2dnUVZ_ tGdnZ2d@comcast .com...[color=blue]
          > Arjen wrote:[color=green]
          > > Arjen wrote:
          > >[color=darkred]
          > >>
          > >> SELECT COUNT (id) GROUP BY name[/color]
          > >
          > >
          > > Ehmm .... SELECT name, COUNT (id) FROM table ORDER BY name[/color]
          >
          >
          > SELECT name, COUNT(id) FROM table GROUP BY name
          >
          > --
          > =============== ===
          > Remove the "x" from my email address
          > Jerry Stuckle
          > JDS Computer Training Corp.
          > jstucklex@attgl obal.net
          > =============== ===[/color]


          Comment

          • Arjen

            #6
            Re: Duplicates

            Jerry Stuckle wrote:
            [color=blue][color=green][color=darkred]
            >>> SELECT COUNT (id) GROUP BY name[/color]
            >> Ehmm .... SELECT name, COUNT (id) FROM table ORDER BY name[/color]
            > SELECT name, COUNT(id) FROM table GROUP BY name[/color]

            AAARCH !!

            Well u know what I mean :-)

            Arjen

            Comment

            • Arjen

              #7
              Re: Duplicates

              Dejan wrote:[color=blue]
              > How cann i display now name and count number in this code?[/color]

              Optianal: SELECT COUNT(id) AS mycounter

              while $row=mysql_fetc h_assoc($q)
              {
              echo "$row['name'] ($row['mycounter'])<br>\n";
              }

              Arjen

              Comment

              Working...