What sql statement will allow me to select the row that was added LAST to a table?
thanks.
Hopefully you have a timestamp column on your table. Otherwise, you can't do it consistently.
Or a column based on a sequence.
Hi
Use Rowid..
Ex:
select * from emp where rowid in (select max(rowid) from emp);
I hope it works..
This does't work. You don't know where new rows are inserted. After rows are deleted, new rows can be inserted in the datablocks of the deleted rows.
ok, say I have a timestamp column in the table.
What sql statment will allow me to select the last row with the latest time stamp.
An SQL example would help,
thanks.
I agree with akkerend. The rowid will yield the last row in the table, not necessarily the last row inserted into the database.
If you have a timestamp column:
select * from emp
where timestamp_col = (select max(timestamp_col) from emp)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks