0

My SQLite table tPeople has a primary key on field fLocation of type UNSIGNED INTEGER (which is not the rowid).

It also has a secondary index on field fLastName of type TEXT which is filled with last names - and it naturally has lots of duplicate keys.

Let's say my display can handle 500 rows at a time so I...

SELECT * FROM tpeople WHERE fLastName = 'Smith' LIMIT 500

...but there could be 2,600 fLastNames equal to 'Smith' or maybe just 3 of them.

How do I select the next 500 rows with fLastName = 'Smith'?

zx485
  • 28,498
  • 28
  • 50
  • 59
Mike at Bookup
  • 1,211
  • 14
  • 32
  • From the SQLite documentation: "...programmers are strongly encouraged to use the form of the LIMIT clause that uses the "OFFSET" keyword and avoid using a LIMIT clause with a comma-separated offset." – Mike at Bookup Apr 06 '16 at 17:29
  • 2
    So use the OFFSET keyword. What specifically is your question? http://stackoverflow.com/q/3325515/62576 – Ken White Apr 06 '16 at 17:30
  • @KenWhite Ah, yes, my question wasn't completely clear. I was looking for a way to create a new SELECT query based on the values from the 500th row returned by the original query. I'm stepping through millions of records and OFFSET will get unwieldy at some point. (And I misinterpreted the SQLite paragraph as saying OFFSET shouldn't be used.) – Mike at Bookup Apr 06 '16 at 17:43
  • Adding **ORDER BY fLastName** wouldn't seem to help as they are all the same name. – Mike at Bookup Apr 06 '16 at 17:49

0 Answers0