Implement recursive query in mysql?

encountered a problem today that requires association replacement between a customer table and a card update table.
the demand is this: some customers change several cards a day, each time the card number will be renewed, the old card number will not be used again. If a customer changes cards four times a day, there will be five card numbers associated with one customer.

< H2 > if the information of the card update table is extracted the next day, it is associated with the customer information table. In fact, only one card number field needs to be changed, but the record of updating the card number four times has to be inserted into the database. The question is, how can it be connected to this customer number from card one to card five in turn to achieve batch insertion? Help! < / H2 >

the current problem is that the customer number in the customer account table to be associated cannot be associated with the card update table because there is no customer number field in the card update table.


act_cd

how do you associate two tables in this case? Then associate the new card number to the customer information and insert it in bulk? The sql statement I think of now is
to query the corresponding body information of the old card number in the new card number column, which means that a customer changes the card once a day and then continues to change the card.
insert into ori_pact
(
ctif_id,
act_cd,
act_tp,
act_typ,
act_limit,
address,
bind_mob,
contact,
cst_sex,
ctif_tp,
id_deadline,
id_no,
id_type,
is_self_acc,
nation,
occupation, < br < sales_flag,

lp.ctif_id,

CASE
WHEN lp.act_cd=uci.oldcard THEN uci.newcard
END act_cd,
-- lp.act_cd,
lp.act_tp,
lp.act_typ,
lp.act_limit,
lp.address,
lp.bind_mob,
lp.contact,
lp.cst_sex,
lp.ctif_tp,
lp.id_deadline,
lp.id_no,
lp.id_type,
lp.is_self_acc,
lp.nation,
lp.occupation,
br,
lp.sales_name
FROM
t_stan_pact lp,update_card_info uci
WHERE
lp.act_cd=uci.newcard AND uci.oldcard
IN
(SELECT
p1.newcard
FROM
update_card_info p1 updatecard info p2
WHERE
p1.oldcard=p2.newcard
)

but after thinking about it, the situation of changing cards many times will not solve the problem

Mar.09,2021

feels better to do
at the business layer. First put the latest id in the loop to query
until the time expires or there is no longer data
. In other words, it is really good for customers to update the card number table without customer fields

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3dcff-2c3ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3dcff-2c3ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?