How to get ROWID in SQLite?
Asked Answered
G

2

55

consider this simple table(tbl1):

A|first letter
B|second letter
C|third letter

first column is letter and second column is desc

I can do this query without any problem:

select * from tbl1 where letter='B'      -->>second letter

My question is: how I can get(retrieve) the ROWID of the result row?

Geny answered 22/3, 2013 at 12:15 Comment(2)
Can you give more detail what you mean?Marigolde
use rowid keyword.. sqlite.org/autoinc.htmlSelfassured
U
136
SELECT rowid, * FROM tbl1 WHERE letter = 'B'
Unreflective answered 22/3, 2013 at 12:50 Comment(3)
how I do it using the function query of SQLiteDatabase in android?Badenpowell
how to retrieve that rowid with get column Index ?Bedard
@NoorHossain In exactly the same way as with any other column.Unreflective
N
0

You can get ROWID as shown below according to the doc:

SELECT rowid FROM person;

Or:

SELECT oid FROM person;

Or:

SELECT _rowid_ FROM person;

In addition, you cannot show ROWID even the commands below:

PRAGMA table_info('person');

Or:

.schema person
Nehemiah answered 3/10, 2023 at 17:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.