question

LalremruataKhiangte-1870 avatar image
0 Votes"
LalremruataKhiangte-1870 asked CarrinWu-MSFT answered

How to insert certain table_1 column value in table_2 along with new user input values

I am stuck and request help. I have an Sqlite3 table and code with PyQt5 in PyCharm. I want to insert id's latest row of table_1 into a "import" column in table_2 simultaneously when a button is click to make new record for/in table_2. [Fetch table_1 id's latest row number and insert into "import" column along with name1 and name2 (user input) text value in table_2 when a button is click.]

Table_1: CREATE TABLE "table_1" ( "id" INTEGER UNIQUE, "first_name" TEXT, "last_name" TEXT, PRIMARY KEY("id" AUTOINCREMENT) )

Table_2: CREATE TABLE "table_2" ( "import" INTEGER, "name1" TEXT, "name2" TEXT )

I have google many website but could not find clue/answer to my problem. There are some code to insert value(s) into another table but they missed out on how to insert into along with capturing the txt_name1 & txt_name2 user's input values.

Thanks in advance.

sql-server-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


If you already know how to insert data into any table using parameters, then maybe consider this statement that consists of two INSERT:

INSERT INTO table_1 (first_name, last_name) values ( ?, ? ) INSERT INTO table_2 (import, name_1, name_2) SELECT last_insert_rowid(), ?, ?

But it is better to also visit the sites that are dedicated to SQLite and Python.

1 Vote 1 ·

I have an Sqlite3 table and code with PyQt5 in PyCharm.

That are not Microsoft product, so better post to a more related forum, like https://sqlite.org/forum/forummain




1 Vote 1 ·

1 Answer

CarrinWu-MSFT avatar image
0 Votes"
CarrinWu-MSFT answered

Hi @LalremruataKhiangte-1870,

Welcome to Microsoft Q&A!

As Olaf said, SQLite is not Microsoft product, suggest that post your question in other related forum. And you could find all products that supported on Microsoft Q&A forum from this link.


Best regards,
Carrin


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.