MySQL是否有可能在插入时合并?

时间:2014-10-31 23:12:50

标签: mysql insert group-concat

我的列有昏迷分隔的id列表。如果脚本试图插入现有行,我想要合并列表。是否可以只使用SQL?这是我的插入脚本:

INSERT INTO Movie ( title, subtitle, year, filmIds, masterIds )
(select originaltitel, originaluntertitel, entstehungsjahr, GROUP_CONCAT(filmid), GROUP_CONCAT(master_id)
from film
where originaltitel is not null
group by originaltitel
)
union
(select titel, untertitel, entstehungsjahr,GROUP_CONCAT(filmid), GROUP_CONCAT(master_id)
from film
where originaltitel is null
group by originaltitel
)

0 个答案:

没有答案