I need to store data on two tables simultaneously.
with first table window having columns (ID, start_time, stop_time, message) and second table windowClients having columns (ID, Clients).
ID is auto-incremented in table window, i want to insert 'Clients' into windowClients with that same ID.
window
ID | start_time | stop_time | message |
---|---|---|---|
100 | 2022-12-03 15:13:00 | 2022-10-03 15:13:00 | hello |
101 | 2022-10-15 13:10:00 | 2022-10-03 15:13:00 | test |
windowClients
ID | Clients |
---|---|
100 | 443 |
100 | 147 |
100 | 600 |
101 | 556 |
101 | 555 |
How should i insert the following data in both of two tables at the same time:
start_time : 2022-12-25 11:11:00
stop_time : 2022-10-26 11:11:00
message : Holiday timeout
Clients : 256, 727, 600, 535
i can do the following but it's probably not a good way.
Insert into window (columns) values (value)
Insert into windowClients (ID, Clients) values ((select max(ID) from window), (443))