I am curious if it's possible to build a SQL query to do what I want. I know I can do it programatically by parsing a table and building an array of recnos, but am curious if any of you experts out there know if there's a simpler/more efficient way to do this?
I have a table that will be queried in a specific order such as:
SELECT * from my_table ORDER by id1,id2,date
The table also has an indexed column called "recno" that allows me to pull a specific row like:
SELECT * from my_table where recno=1234567
I assume the recno values are not in any specific order.
What I'd like to be able to do is pull a specific row, but instead of getting the row with recno=1234567, I'd like to be able to pull the row before it, the row after it, or x rows before/after, according to the "ORDER BY attributes" in the first example.
In other words, give a recno (specific row) as a reference, how can I pull a row before/after according to a certain sort order?
What do you think is the best approach to doing this? I'm working an extremely large table so the more efficient this query is, the better things will be.
Thanks for any advice!
I'm using MariaDB