Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update on UNIQE field

Status
Not open for further replies.

max1x

Programmer
Jan 12, 2005
366
US
I have a tbale userId = PK and AUTO_INCREMENT and e-mail = unique. When a new user is added, I use the INSERT key, but if an existing user updates their profile, I use REPLACE. This though treats the updated record as a new entry and updates the AUTO_INC (which I guess if fine).

Is there a way I can simply UPDATE the record, w/o checking if it already exists first, so that AUTO_INC remins at the proper iteration?
 
Check the manual for the INSERT command, and read about the ON DUPLICATE KEY clause.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
r937, the reason, why UPDATE was not being used, is how Data Submitio and Update happen from the same site - based on an alias id built in LDAP servers. It's not a standard form where changes can be made.

For now, I have gone with update record, post an INSERT, if a Duplicate on Key is error is thrown.

DonQ,

I will read up on it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top