Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将多行插入到具有超级/子类型的MySQL表中_Mysql_Sql_Inheritance - Fatal编程技术网

将多行插入到具有超级/子类型的MySQL表中

将多行插入到具有超级/子类型的MySQL表中,mysql,sql,inheritance,Mysql,Sql,Inheritance,我在MySQL中有以下子/超类型安排: 我还有一个CSV行,需要进入rnaseq_voom表,因此我想将CSV加载到一个临时表中,将其连接到bmt_gene表中,然后批量插入到supertypernaseq中 但是,我需要插入子类型,但是我不能使用SET@LAST=LAST\u insert\u ID()因为这将只得到插入父表的最后一行,而不是相关行 我可以同时插入两个表吗?否则,如何将多行插入到超级/子类型关系中。如果数据中有一组列唯一标识插入的行,则可以执行以下操作: INSERT INT

我在MySQL中有以下子/超类型安排:

我还有一个CSV行,需要进入rnaseq_voom表,因此我想将CSV加载到一个临时表中,将其连接到bmt_gene表中,然后批量插入到supertype
rnaseq

但是,我需要插入子类型,但是我不能使用
SET@LAST=LAST\u insert\u ID()因为这将只得到插入父表的最后一行,而不是相关行


我可以同时插入两个表吗?否则,如何将多行插入到超级/子类型关系中。

如果数据中有一组列唯一标识插入的行,则可以执行以下操作:

INSERT INTO rnaseq (columns) SELECT columns FROM temp_table;
INSERT INTO rnaseq_voom (id,more_columns)
    SELECT r.id,more_columns FROM rnaseq r JOIN temp_table t USING (key_columns)
其中,
columns
是要插入到
rnaseq
中的一组列,
more\u列
是要插入到
rnaseq\u vom
中的列,
键列
是唯一标识临时表行的列(在该行的
rnaseq
中查找id)