neo_the_1
April 18th, 2007, 09:28 AM
hi all,
is there a way to query the last entered record in a table?
thanks
is there a way to query the last entered record in a table?
thanks
|
Click to See Complete Forum and Search --> : last record neo_the_1 April 18th, 2007, 09:28 AM hi all, is there a way to query the last entered record in a table? thanks Shuja Ali April 18th, 2007, 10:09 AM Assuming that your table has some kind of key (an autogenerated number or something of a similar sort), then you can try doing thisSelect Top 1* From Table1 Order By PrimaryKey Field DescYou have not mentioned which Database you are using and what is your table structure. That would help in giving a proper solution. davide++ April 19th, 2007, 10:24 AM Hi all. It depends which database you're using and how your table is defined. If we agree with Shuja's assumptions (reasonable in order to have a correctly designed table) you'll can write also SELECT * FROM MY_TABLE WHERE KEY_FD = (SELECT MAX(KEY_FD) FROM MY_TABLE) where KEY_FD is the key field that contains autogenerated numbers. DanielaTm April 25th, 2007, 03:17 AM If it is sqlserver, You could use SELECT IDENT_CURRENT('tablename') - This function returns the last IDENTITY value produced in a table SELECT @@IDENTITY. It returns the last IDENTITY value produced on a connection SELECT SCOPE_IDENTITY() This new function returns the last IDENTITY value produced on a connection and by a statement in the same scope, regardless of the table that produced the value. Hope it helped codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |