Re: Newbie database question
| From: | Peter J. Schoenster | Date: | Sun, 13 Jan 2002 20:23:47 +0000 |
| Subject: | Re: Newbie database question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-80374@lists.php.net to get a copy of this message | ||
On 13 Jan 2002, at 12:51, Dean Ouellette wrote:
> I am entering info from form into database, is there a way to check
> say firstname, lastname and address to see if it is a duplicate to
> what is already in database and if it is then just enter any new
> information they may enter and not create a new entry
If using mysql you can use REPLACE rather than insert (if you
also pass a unique key/value with your statement).
Of course you have some means of identifying a record. Perhaps it
is a combo of firstname, lastname and address but that's not very
good.
I recall having this situation appear for me in the past ... I think it
may be an error in design when one cannot be sure if it's an
INSERT for a new record or an UPDATE to an existing record.
Perhaps you could dissuage me otherwise with your example.
Peter
---------------------------
"Reality is that which, when you stop believing in it, doesn't go
away".
-- Philip K. Dick