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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to return update value?

Status
Not open for further replies.

majjk

Technical User
Dec 9, 2004
7
GB
I'm doing the following:

INSERT INTO ordernumber (id,count) VALUES (123,1) ON DUPLICATE KEY UPDATE count=count+1

what I would like to know is what the "count" value is after this operation. is it possible to include some kind of SELECT in this query so that I will know what the "count" value is in the end?

ideas?
 
but isn't there a (slight) possibility that the database might have been updated again by the time I make my SELECT? I might not get the value that I'm looking for. I don't necessarily want the latest value, but the value that I entered.

Is there no other way around this? What I want to do is basically INSERT/UPDATE and then return the value that was entered into the database.
 
the value that was entered" should be known to you ;-)

wrap the UPDATE/SELECT in a transaction block

r937.com | rudy.ca
 
That could very well be what I'm looking for... thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top