SQLite provides a way to get the N-th row given a SQL statement, with LIMIT 1 and OFFSET <N>.

Can the reverse be done in an efficient way? For example, given a table with 1million names, how can I return the row number for a particular element? i.e. something like

 SELECT rownum FROM
        (SELECT name,<rownum> FROM clients
                WHERE name='foo' ORDER BY name)

I tried having rownum as the rowid, but it doesn't work since the names were not originally entered alphabetically (and wouldn't work as new names are entered).

I need to synchronize a virtual list, so that the selected list # item corresponds to 'foo'.

Any ideas?

jp

Reply via email to