Select a specific index row in sqlite

20,626

Typically to get a specific row you can always request them by rowid, e.g.

SELECT name FROM UnknownTable WHERE rowid = 1;

However, there are some atypical situations that preclude this. You'll really want to read up on rowids to ensure that your table is going to behave as you want.

Share:
20,626
gabboSonc
Author by

gabboSonc

Updated on July 03, 2020

Comments

  • gabboSonc
    gabboSonc almost 4 years

    I have an index and I need to find out what is the row in a table with that index, in SQLite. Example:

    Index = 1

    Table:

    ID   -    Name
    aa1      John
    aa2      Mark   <-- I need this row
    aa3      Lucy
    aa4      Jim 
    

    Which is the correct SELECT that I can use to solve my problem?

  • Jeremy Caney
    Jeremy Caney almost 4 years
    This doesn’t answer the question. They want to select the row by its index, not by its ID. See the accepted answer for how they solved it.
  • Sam
    Sam almost 4 years
    Hey Prajwal, thanks for your efforts. It can be tough answering questions on StackOverflow but don’t give up, your first attempt was better than most. Formatting really helps and like this question, the devil is in the detail.—It’s always worth a re-read of the question before posting. Formating cheatsheet: stackoverflow.com/editing-help