Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Mysql Help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Mysql Help

 Post Reply Post Reply
Author
Diddl View Drop Down
Newbie
Newbie
Avatar

Joined: 11 September 2003
Location: Denmark
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diddl Quote  Post ReplyReply Direct Link To This Post Topic: Mysql Help
    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.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 28 June 2005 at 12:47pm
If you are using SQL Server you can use

SELECT @@IDENTITY As ID
Back to Top
Diddl View Drop Down
Newbie
Newbie
Avatar

Joined: 11 September 2003
Location: Denmark
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diddl Quote  Post ReplyReply Direct Link To This Post Posted: 28 June 2005 at 1:28pm
I got the problem figured.. i was using mySQL, so IDENTITY wouldn't have worked.
Back to Top
jgilc View Drop Down
Newbie
Newbie
Avatar

Joined: 22 June 2005
Location: Cuba
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote jgilc Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.