title: php+mysqlupdate
body: <p>I have the following mysql table data
  where primary key is (id,seq)</p>
  
  <pre><code>id  name  seq
  ------------
  1    a     1
  1    b     2
  1    c     3
  1    d     4
  </code></pre>
  
  <p>Now what i  have to do is delete the 1st row and reduce the values of seq in remaining rows by 1</p>
  
  <p>I am using php PDO. And i have deleted the first row and then  fetched the remaining  rows in $result and then did following</p>
  
  <pre><code>while($row1 = mysql_fetch_array($result,MYSQL_ASSOC))
  
   $dbh-&gt;exec("update tablename set seq = seq-1 where id  = $row1['id'] and seq &gt; 1 ");
  </code></pre>
  
  <p>I am getting following error</p>
  
  <p>SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry  for key 'PRIMARY'</p>
  
  <p>could anyone help me on this?</p>