MySQL Forums
Forum List  »  General

Insert into table with same name
Posted by: Vivan Jert
Date: June 14, 2023 08:47AM


I need help with query that will take all tables with prefix "tifa_" in "centraldb" database and copy all data in same name table that ends with "_hist". Column name should be matched. as_of_date need to be yesterday day when running the query.

I have around 70 tables and this is example of 4 tables:


tifa_empcont ----------- ec_billed_amt_01
tifa_empcont ----------- ec_billed_amt_02
tifa_empcont----------- ec_billed_amt_03
tifa_empcont----------- ec_billed_amt_04
tifa_empcont----------- ec_billed_amt_05

tifa_empcont_hist----------- ec_billed_amt_01
tifa_empcont_hist----------- ec_billed_amt_02
tifa_empcont_hist----------- ec_billed_amt_03
tifa_empcont_hist----------- ec_billed_amt_04
tifa_empcont_hist----------- ec_billed_amt_05
tifa_empcont_hist----------- as_of_date

tifa_employer----------- emp_aca_4980h_trans_flag
tifa_employer----------- emp_aca_98_offer_flag
tifa_employer----------- emp_aca_ale_member_flag
tifa_employer----------- emp_aca_auth_trans_flag
tifa_employer----------- emp_aca_codes_flag

tifa_employer_hist----------- emp_aca_4980h_trans_flag
tifa_employer_hist----------- emp_aca_98_offer_flag
tifa_employer_hist----------- emp_aca_ale_member_flag
tifa_employer_hist----------- emp_aca_auth_trans_flag
tifa_employer_hist----------- emp_aca_codes_flag
tifa_employer_hist----------- as_of_date

Thank you!

Options: ReplyQuote

Written By
Insert into table with same name
June 14, 2023 08:47AM

Sorry, only registered users may post in this forum.

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.