SQLite Forum

How to insert certain table_1 column value in table_2 along with new user input values
Login
One change which will help is to create table_1 thusly:<code>
  CREATE TABLE table_1 (
   id INTEGER PRIMARY KEY,
   first_name TEXT,
   last_name TEXT
  )
</code>, which will ensure that the "ROWID" is identical to the id. The utility of that identity should become obvious as you study the <u>[last_insert_rowid()] (https://sqlite.org/lang_corefunc.html#last_insert_rowid)</u> function, which you will probably want to use for that 2nd insert operation.

You should perform both inserts within the same transaction unless you can be absolutely certain that no other inserts can be made to happen between your two, linked inserts.

You probably don't need the AUTOINCREMENT feature. The ROWID values are going to be unique and normally increment anyway except when deletions permit reuse of their old values. Likewise, there is no reason to declare a primary key to be unique, and sometimes there is reason not to do so. (That's another topic.)