select distinct(headlines), count(headlines)
from table
group by headlines

-----Original Message-----
From: David Shapiro [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 03, 2002 8:40 AM
To: 'Michelle de Beer'; mysql list
Subject: RE: Select and count duplicates




Run this query as rs1:
select distinct scary_words from monsters_table; 

String word;
String query;
Int count;

while rs1.next() {
        word = rs1.getString();
        // Run this sql query as rs2
        query = 'select count(*) from monster_table where scary_words="' +
word + '"';

                .
                .
                .
                while rs2.next() {
                        // display your results (i.e., word count)

        
Use it to count them:
for
select count(*) 

-----Original Message-----
From: Michelle de Beer [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 03, 2002 7:27 AM
To: mysql list
Subject: Select and count duplicates


I have a column containing headlines. In this column
there are some duplicates, like this:
-----------
monsters
headline1
monsters
halloween
monsters
halloween
...
----------

How can I get a result like this instead?
HEADLINE   | HITS
-----------------------
monsters   | 3
halloween  | 2
headline1  | 1
-----------------------

Any thoughts?
// Michelle

<Sql query>

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to