Print Page | Close Window

Mysql Help

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=15638
Printed Date: 29 March 2026 at 4:24pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Mysql Help
Posted By: Diddl
Subject: Mysql Help
Date Posted: 28 June 2005 at 12:14pm
Hi

I need somehow to retrieve the auto-increment of and insert statement.
I know i need to use "Select last_inserted_id()" but i can't figure out how, everything i tries won't work, and looking through the net, isn't helpful either.

I need it done in asp

Can someone plz help me - i need in pretty quick.



Replies:
Posted By: Mart
Date Posted: 28 June 2005 at 12:47pm
If you are using SQL Server you can use

SELECT @@IDENTITY As ID


Posted By: Diddl
Date Posted: 28 June 2005 at 1:28pm
I got the problem figured.. i was using mySQL, so IDENTITY wouldn't have worked.


Posted By: jgilc
Date Posted: 30 June 2005 at 8:56am
To Diddl: May be this is not the optimum but it work.
First: recognize between your inserted fields some that you are sure    they  conform a key to your table. This is that with their values you can select a unique row corresponding to your table and no more.

Second: suppose they are kfield1, kfield2, ...
kfieldn and  that you inserted kvalue1, kvalue2, ... and so on in those fields. They are never Null because they are a key.

Then: make a request  using this key
    select id_TableRow where kfield1=kvalue1 and ... and kfieldn=kvaluen

This is because you will not know if another user makes an insert before you request your id.
 
Good Luck, I am Saved.


-------------
This forum is great



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net