Guest Seph Posted March 31, 2006 Share Posted March 31, 2006 Good Monring people!I'm in a infinty looping, and to resolv this i must select only the last register of my database, ho can i do this?Thanks Link to comment Share on other sites More sharing options...
pulpfiction Posted March 31, 2006 Share Posted March 31, 2006 SQL = "SELECT * FROM TBL_NAMESet RS = Server.CreateObject("ADODB.Recordset")RS.Open SQL, MyConn RS.MOVELAST 'This will take you to the last record of the recordset I guess this is what you are looking for.. HTH Link to comment Share on other sites More sharing options...
Yahweh Posted April 1, 2006 Share Posted April 1, 2006 SQL = "SELECT * FROM TBL_NAMESet RS = Server.CreateObject("ADODB.Recordset")RS.Open SQL, MyConn RS.MOVELAST 'This will take you to the last record of the recordset I guess this is what you are looking for.. HTH<{POST_SNAPBACK}> That's a bad way to select the last registered user, because it causes MySQL to cache all of the records in the database, when it only makes use of a single record.A better SQL statement is:Select * From Your_TABLE ORDER BY ID Desc Limit 1 Basically, this just reverses the order the table and selects one record, its much faster, doesn't require MySQL to cache all the data in the table, and doesn't require an "RS.Movelast" line. Link to comment Share on other sites More sharing options...
pulpfiction Posted April 4, 2006 Share Posted April 4, 2006 What Seph wants is to select the last register, but when you order the last register may be different from the actual one. correct me if i am wrong. Link to comment Share on other sites More sharing options...
Yahweh Posted April 5, 2006 Share Posted April 5, 2006 What Seph wants is to select the last register, but when you order the last register may be different from the actual one. correct me if i am wrong.<{POST_SNAPBACK}> It could only do that if he orders his list by something other than the unique ID of his users (such as ordering them by name).But if Seph is anything like me, he most likely has a uniqueID assigned to each record that increases by 1 for each record. Then the newest user is the one with the largest ID, and ordering by "ID DESC Limit 1" automatically selects the single record with the largest ID. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now