MySQL Forums
Forum List  »  Newbie

Re: Copying seasonprices to next year
Posted by: Tito St
Date: July 12, 2021 05:00AM

Ok, I changed the code and it is almost working.

SELECT * FROM SEASON_TABLE;

insert into SEASON_TABLE
select
Null, -- autoincrement field replace ID with Null
house,
date_from + INTERVAL 1 YEAR - INTERVAL 1 DAY,
date_to + INTERVAL 1 YEAR - INTERVAL 1 DAY,
price
from SEASON_TABLE
where year(date_from)=2021 OR
year(date_to)=2021;

The only thing I am missing is to NOT create new records for a house that already has 2022 data filled in ... So I need a loop? Something like while a house has no 2022 in date-from or in date-to then go and excute.

Your help is much appreciated.

Options: ReplyQuote


Subject
Written By
Posted
Re: Copying seasonprices to next year
July 12, 2021 05:00AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.