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.
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