Thank you for the email.  Following is the php code
but it doesn't work.

<?
include ("connect_my_db.inc");

connect_my_db();

$result = mysql_query ("SELECT DISTINCT id FROM
my_rank WHERE rank='a'");

while ($row = mysql_fetch_array($result))
{
$id = substr("$row[id]", 0, 8);

$query ="
        SELECT id 
        FROM my_rank 
        WHERE id LIKE \"$id%\" 
        GROUP BY id 
        HAVING COUNT(*) > 1
        ";

$result1 = mysql_query($query);

        while ($row = mysql_fetch_array($result1))
        {
         echo "$row[id]<br>";
        }
}
?>


Best regards,

James

--- Jay Blanchard
<[EMAIL PROTECTED]> wrote:
> [snip]
> I have over 68,000 records in a table with unique ID
> field that has 10 chars.  Need to create a query to
> find all matching or duplicate IDs up to 8 chars. 
> (Eg. 12345678%%)
> 
> Can anyone help me?
> [/snip]
> Try
> 
> select ID
> from   tblFOO
> group by ID
> having count(*) > 1
> 
> HTH!
> 
> Jay Blanchard
> Applications Development
> nii communications, inc.
> 210-403-9100 x285
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.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

Reply via email to