J
J
Juhani Lahtinen2020-03-18 15:10:45
SQLite
Juhani Lahtinen, 2020-03-18 15:10:45

Inserting a record into one table when there is a record in another table?

Good afternoon.

There is a table tmp_id-data two columns (id-data, time_connect).
5e720ea32d059119926892.png

The second table is info_table (id-data, data, comment).
5e720f46ef9f6669546055.png

What do you need. You need to insert an entry into the first tmp_id-data table only if there is id_data in the info_table table. If there is no date, do not insert anything.

Now I'm doing a check, if there is id-data in table 2, I'm doing an INSERT, but I would like to do it at once.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dftusert, 2020-03-18
@nukler

If insert into select is considered "do it once", then something similar to:

INSERT INTO "tmp_id-data"("id-data", "time_connect")
SELECT "id-data", 'здесь необходимый для вставки time_connect'
FROM "info_table"
WHERE "id-data" = 'здесь необходимый для вставки id-data'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question