ayyob khademi
ayyob khademi

Reputation: 573

How to get ROWID in SQLite?

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?

Upvotes: 57

Views: 84080

Answers (2)

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

Upvotes: 1

CL.
CL.

Reputation: 180010

SELECT rowid, * FROM tbl1 WHERE letter = 'B'

Upvotes: 137

Related Questions