为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:8
【操作系统】:centos7
【CPU】: inter
【问题描述】*: 批量插入sql报错,插入数据的表的其中一个字段是另一张表的id
insert into "MIDDLEG"."t_sys_config_dictionary"
( "dictionary_name", "dictionary_value", "is_deleted", "sys_config_id", "dictionary_enable")
VALUES
('测试1','1','2',(select id from "MIDDLEG"."t_sys_config_parent" where param_value = 'warehouseManufacturer') ,'1'),
('测试2','2','2',(select id from "MIDDLEG"."t_sys_config_parent" where param_value = 'warehouseManufacturer') ,'1');
试下这种笛卡尔积实现拼接多行多列内容
insert into "MIDDLEG"."t_sys_config_dictionary"
( "dictionary_name", "dictionary_value", "is_deleted", "sys_config_id", "dictionary_enable")
select "dictionary_name", "dictionary_value", "is_deleted", "sys_config_id", "dictionary_enable"
from (
select '测试1' "dictionary_name" , '1' "dictionary_value", '2' "is_deleted", '1' "dictionary_enable"
union all
select '测试2' "dictionary_name" , '2' "dictionary_value", '2' "is_deleted", '1' "dictionary_enable"
) a,
(
select id "sys_config_id" from "MIDDLEG"."t_sys_config_parent" where param_value = 'warehouseManufacturer'
) b;
这种写法只插入一条是可以执行成功的
如果把select的部分直接写值,也是可以插入多条的
我现在想多条还需要select怎么办