Reputation:
I'm using a PostgreSQL database and have one table "event_date" with "started_at" (DATE
format, e.g. '2019-10-29') values which are also the PRIMARY KEY in this table.
Now I want to insert this "started_at" value in another table "event_days" but increasing the date by x days.
Can someone explain how to achieve this? Thanks a lot!
Upvotes: 0
Views: 684
Reputation: 133380
if you really need insert the related record you could use a insert select
insert into event_days(started_at, location , moderator)
select started_at + interval '10 day', 'hall 5' , 'Tom'
from event_date
Upvotes: 0
Reputation:
Use an INSERT with a SELECT:
insert into other_table (started_at, location, moderator)
select started_at + 42, 'Hall 5', 'Tom'
from event_days;
+ 42
add 42 days to the date value.
Upvotes: 1