You are here: Re: Cant alter data in primary key fields « All PHP « IT news, forums, messages
Re: Cant alter data in primary key fields

Posted by J.O. Aho on 01/09/06 18:02

jj wrote:
> Hi all
>
> All of a sudden I cant alter values in rows where the column is a primary
> key. It just reverts to the old value that was there if I try to make any
> changes.
>
> If I try changing a value on any other (non-primary key) column , it changes
> the data no problem.


Control that the value you change to aren't already in the table

eg table Simple
Id Name
A Carl
B Buddy
C Cheng
D David
E Earl

ID is the primary key.

UPDATE Simple SET Id='C' WHERE Id='A';

This will fail as there already is a row with the Id=C (Cheng) and with the
primary key there is only allowed to be one of each.

While the Name isn't a primary key, you could do

UPDATE Simple SET Name='Cheng' WHERE Id='A';

As there aren't any restrictions.


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация