card_exhibitor 是展商表
card_card 是名片表
展商表 里之前staff_card 字段存储的是员工的card id,用逗号分隔。
后来考虑到 员工card 会很多,所以设计了中间表card_exhibitor_staff_r
将逗号分隔的数据查出来导入到 中间表
sql 如下,备注下,方便以后写类似语句。
INSERT INTO card.card_exhibitor_staff_r
(id, staff_card_id, exhibitor_id, create_time)
select uuid_short(),cc.id as cardId,ce.id,ce.create_time
from card_exhibitor ce
left join card_card cc on find_in_set(cc.id,ce.staff_card)
where staff_card != ''
and cc.id is not null;