Re: general theory behind 'primary_key' & 'auto_increment' flags, and ON DUPLICATE KEY UPDATE ?
| From: | Bastien Koert | Date: | Wed, 15 Jul 2009 13:37:40 +0000 |
| Subject: | Re: general theory behind 'primary_key' & 'auto_increment' flags, and ON DUPLICATE KEY UPDATE ? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46309@lists.php.net to get a copy of this message | ||
On Wed, Jul 15, 2009 at 9:21 AM, Govinda<govinda.webdnatalk@gmail.com> wrote:
> Reading docs.. I want to be sure of things... have your verification of my
> understanding(s)-
>
> Does setting a mysql db column (say "myPrimarykeyID") with the
> 'primary_key'
> & 'auto_increment' flags totally negate the logic for ever having to use ON
> DUPLICATE KEY UPDATE in an INSERT?
>
> Or is it that I can do an INSERT with SET
> myPrimarykeyID=someAlreadyExistingVal, a=1, b=2.... ON DUPLICATE KEY UPDATE
> a=edited1, b=edited2 ...
>
> I am trying to learn/work out the mysql/php code that will allow me to
> either create *or* edit a record, in one fell swoop.
>
> Thanks for any insight!
> -Govinda
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
If that is the goal use the REPLACE INTO sql syntax
You really don't want to allow duplicates in primary keys, that
completely negates the usefulness of that key
--
Bastien
Cat, the other other white meat