List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:March 22 1999 2:06pm
Subject:Re: Primary Key trouble
View as plain text  
Andy Harrison wrote:
> 
> I'm working on getting Access to use my mySQL database and I've had a
> lot of success.  But now I'm stuck on something that I just can't
> knock.  In order for the myAccess add-in to work 100%, you have to have
> a primary key defined.  No problem, I had it working fine.  Access could
> enter data, no sweat.
> 
> After I got it working, I went and made some changes and basically
> recreated the mySQL database I had going.  Now it's time for the primary
> key.  I'm keying off of a char(50) field called simply Name.  There are
> no duplicate values in this.  I combed the entire table several times
> ensuring there were no dupes, plus had someone else comb through it as
> well.  There are 552 rows of data and I'm 110% certain that no two Name
> fields contain the same data.
> 
> Now, when I go to create the primary key on the name field, I modify the
> Name field appropriately, click the Alter Table button, and I get:
> 
> Executing "alter table ip add primary key (Name(30)) " -> * ERROR *
> Can't write, duplicate key in table 'A-280'
> 
> (the reason it says (Name(30)) in this example is because I was trying a
> smaller key to see if that helped)
> 
> I'm not sure quite what that error message means.  I looked at row 280
> to see if that contained a dupe and it didn't.
> 
> Can anyone help me out?  Thanx!

Hi Andy

We need the charset you use with mysql, because the sorting order depends on that.
If you want to find the "duplicate" yourself, you can use:
SELECT
	t1.Name
FROM
	table AS t1
	, table AS t2
WHERE
	t1.Name like t2.Name
GROUP BY
	t1.Name
HAVING
	COUNT(*) > 1

Hope this helps
Christian

Thread
Primary Key troubleAndy Harrison21 Mar
  • Primary Key troublesinisa21 Mar
  • Re: Primary Key troubleChristian Mack22 Mar
  • Re: Primary Key troubleAndy Harrison22 Mar