N
N
Nikita2018-08-05 20:32:33
SQL
Nikita, 2018-08-05 20:32:33

How to add an entry with a many to many relationship?

Good day!
There are three tables:
day_table, task_table, day_task
Day_table stores days, and you need to link tasks to them that are added to task_table using many to many links. I have already set up connections in the database, but here's how to make a query so that when I insert a task, the day_id value (I know it) and task_id are written to the day_task table? Is there any way to find out what id the record received by the results of INSERT?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bkosun, 2018-08-05
@dbmb

Use the last_insert_rowid function
https://www.sqlite.org/c3ref/last_insert_rowid.html
PS Use transactions to avoid making a mistake.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question