"Andrea" <[EMAIL PROTECTED]> wrote:
> 
> In MySql I create this table:
> 
> CREATE TABLE `prova` (
>  `Gruppo` int(11) NOT NULL default '0',
>  `Prog` int(11) NOT NULL default '0',
>  `Descrizione` varchar(100) default '',
>  PRIMARY KEY  (`Gruppo`, `Prog`)
> ) TYPE=MyISAM;
> 
> Running this:
> UPDATE Prog SET Prog=Prog+1 WHERE Gruppo=16 AND Prog>=1
> 
> I get "Duplicate entry".
> 
> Is this a MySql bug?

No. Row with Prog=3 and Gruppo=16 may be found before row with Prog=4 and Gruppo=16. 
In this case UPDATE gives you error "Duplicate entry" because you already have row 
with Prog=4 and Gruppo=16.

>How can I do this?

Use ORDER BY clause in UPDATE statement:
        http://www.mysql.com/doc/en/UPDATE.html

ORDER BY is supported from v4.0.0.



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to