>> I get Duplicate entry errors quite frequently. As a rule in these

Well, as it turns out I found the solution right now myself. I am
testing locally (so nobody touches the tables but me) and delete
entries before I insert them again.

Here I have that strange error! The table is ok. What's
happening?

Very easy, but your would not expect MySQL to behave that way,
would you? Do you see what causes the error?

DELETE FROM sendIssue
        WHERE idEdIssue = '117' 
                AND titelIssue = 'Tipp: Leben retten '

INSERT INTO sendIssue 
        (idEdIssue, titelIssue, versionIssue, itemIssue) 
        VALUES ('117', 'Tipp: Leben retten ', 'h', 'etc.

Duplicate entry '117-h-Tipp: Leben retten' for key 2

The key value is 'Tipp: Leben retten ' and is followed by a
white space (in both cases, of course). If I trim the value,
things are fine. This is the definition:

CREATE TABLE sendIssue (
   idIssue smallint(5) unsigned DEFAULT '0' NOT NULL auto_increment,
   idEdIssue smallint(5) unsigned DEFAULT '0' NOT NULL,
   titelIssue varchar(100) NOT NULL,
   versionIssue char(1) NOT NULL,
   itemIssue mediumtext NOT NULL,
   PRIMARY KEY (idIssue),
   UNIQUE ivi (idEdIssue, versionIssue, titelIssue)
);

So, I assume that the value has the white space, but the key has
not. Therefore the record is not found. Well, it appears to me
that I work with a combined key here and don't use the middle
value in my delete query. It doesn't matter if I truncate the
space.

In the other cases, I have keys on single fields, but I don't
trim the values. I will try this.

Am I right in my diagnosis? And if so, what does this tell about
query design? Or is something totally different going on here?

One thing for sure: in the case I observed I can produce the
desired result: error with sace, fine without.


-- 
Herzlich
Werner Stuerenburg            

_________________________________________________
ISIS Verlag, Teut 3, D-32683 Barntrup-Alverdissen
Tel 0(049) 5224-997 407 · Fax 0(049) 5224-997 409
http://pferdezeitung.de



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