Thanks for your replies
Arun Giridhar, I have tried last_insert_id() , but, it works just after an insert, i guess. I have posted its working too.
I found out
LAST_INSERT_ID() (with no argument) returns a BIGINT (64-bit) value representing the first automatically generated value that was set for an AUTO_INCREMENT column by the most recently executed INSERT statement to affect such a column.
Claude Moore, Thanks, googling it. Someone suggested for a lock before saving, but that would not be good one i guess.
I found this problem interesting one, did a lot of googling, but, couldn't find any solution. Lets learn something new then.