Search code examples
androidsqliteselect-insert

Android SQLite Insert-Select


There are two different methods for inserting a row into table:

  • execSql, using it I can execute sql statements with SELECT - INSERT. But it doesn't return id of new row.
  • different inserts - I can get insert-id here, but I can't create insert queries with substitution values from another table.

I can split my query into two, but isn't it slower, than one query?


Solution

  • Do your insert however you like, then execSql "select last_insert_rowid()".