jet icon indicating copy to clipboard operation
jet copied to clipboard

How to get rowid in sqlite database ?

Open ibadi-id opened this issue 3 years ago • 1 comments

I need to retrieve row id from sqlite table, my query like so :

SELECT(table.Account.AllColumns).FROM(table.Account)

I can't get the row id from the table, maybe you have a solution?

I think in generating tables and models, we should add:

Rowid int

ibadi-id avatar Mar 03 '22 10:03 ibadi-id

Hi @ibadi-id. Check raw expression and faq.

stmt := SELECT(
        Raw("rowid").AS("row_id"),
        Account.AllColumns,
    ).FROM(Account)

var dest struct {
    RowID int64
    model.Account
}

err := stmt.Query(db, &dest)

go-jet avatar Mar 03 '22 18:03 go-jet