logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Get Last Row

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Thu Mar 12, 2009 4:09    Post subject: Get Last Row Reply with quote

I'm using AUTO_INCREMENT in my tables to give them unique ID's. What I'm trying to do is get the value in column "id" of the most recent row addition.

I've searched on google and found a few things that I thought would work but my limited knowledge of MySQL is preventing me from solving the problem on my own. ><

I can easily set a variable in the database to keep track of the number of rows but I was hoping to avoid that.

Would someone mind helping me out with this? I appreciate it. Smile
Back to top
View user's profile Send private message
Quixsilver



Joined: 20 Jan 2009
Posts: 30

PostPosted: Thu Mar 12, 2009 6:11    Post subject: Reply with quote

select max(id) from <table>;

Should work... if it doesn't, I'm installing Oracle lol.
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Thu Mar 12, 2009 6:45    Post subject: Reply with quote

Awesome, it worked. Thanks Smile
Back to top
View user's profile Send private message
Borys



Joined: 21 May 2008
Posts: 10
Location: Poland

PostPosted: Thu Mar 12, 2009 9:16    Post subject: Reply with quote

In MySQL 4.1: SELECT LAST_INSERT_ID();
Read all about this to avoid mistakes using it
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group