Is it possible to get a table record depending on the row number?
For example, I have a table with 40 records and I need to get the 27th record.
I need some query like SELECT * FROM my_table WHERE **ROWNUM** = 27
.
Is it possible to get a table record depending on the row number?
For example, I have a table with 40 records and I need to get the 27th record.
I need some query like SELECT * FROM my_table WHERE **ROWNUM** = 27
.
You are looking for offset
:
select t.*
from my_table t
order by ??? -- you need to specify a column or expression here
limit 1 offset 26;
Two notes. There is no such thing as the 27th row of a table. SQL tables represent unordered sets. There is only an ordering if a column specifies the ordering. That is the purpose of the order by
. Often this might be the primary key for the table.
Second, the offset (unlike most things in SQL) is zero-based. So an offset of "1" means "skip one record" -- or "start with the second". Hence an offset of "26".
If I have understood you correctly, you are looking for simething like this?
SELECT *
FROM some_table t
where @row = 26;