I have a one table question_table
and one ImageButton
(Back). I need to get the last inserted record from the database after clicking on t
The previous answers assume that there is an incrementing integer ID column, so MAX(ID)
gives the last row. But sometimes the keys are of text type, not ordered in a predictable way. So in order to take the last 1 or N rows (#Nrows#) we can follow a different approach:
Select * From [#TableName#] LIMIT #Nrows# offset cast((SELECT count(*) FROM [#TableName#]) AS INT)- #Nrows#