c_me_7 Posted May 6, 2006 Share Posted May 6, 2006 HiI need to retrieve the autonumber of the last record i added to my Property table.The autonumber attribute is called propertyIDregards Link to comment Share on other sites More sharing options...
Nakor Posted May 7, 2006 Share Posted May 7, 2006 SELECT propertyID FROM tablename ORDER BY propertyID DESC LIMIT 1 Link to comment Share on other sites More sharing options...
c_me_7 Posted May 7, 2006 Author Share Posted May 7, 2006 SELECT propertyID FROM tablename ORDER BY propertyID DESC LIMIT 1 <{POST_SNAPBACK}> it dont work man :)If you dont mind can you send me your email address and i wil winzip you the filesthanks for you reply Link to comment Share on other sites More sharing options...
justsomeguy Posted May 10, 2006 Share Posted May 10, 2006 That SQL statement does work, so the problem is not the SQL. You can also do this: SELECT MAX(propertyID) AS propertyID FROM tablename Link to comment Share on other sites More sharing options...
ray Posted May 11, 2006 Share Posted May 11, 2006 select @@identityIm using it and it seems to work fine Link to comment Share on other sites More sharing options...
aspnetguy Posted May 11, 2006 Share Posted May 11, 2006 That SQL statement does work, so the problem is not the SQL. You can also do this:SELECT MAX(propertyID) AS propertyID FROM tablename <{POST_SNAPBACK}> I might not be working considering that statement only works in MySql. What database are you using??? Link to comment Share on other sites More sharing options...
c_me_7 Posted May 11, 2006 Author Share Posted May 11, 2006 Thanks for your repliesApologies, i failed to mention that I am using Microsoft Access.Regards I might not be working considering that statement only works in MySql. What database are you using???<{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
aspnetguy Posted May 11, 2006 Share Posted May 11, 2006 try this SELECT TOP 1 propertyID FROM tablename ORDER BY propertyID DESC Link to comment Share on other sites More sharing options...
justsomeguy Posted May 11, 2006 Share Posted May 11, 2006 I might not be working considering that statement only works in MySql. WhatIs MAX only available in MySQL? I thought most of the aggregate functions are part of the SQL standard. Link to comment Share on other sites More sharing options...
aspnetguy Posted May 11, 2006 Share Posted May 11, 2006 Is MAX only available in MySQL? I thought most of the aggregate functions are part of the SQL standard.<{POST_SNAPBACK}> not sure, I was refering to LIMIT 1 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