Sql 大量插入的建议
我有以下表格:Sql 大量插入的建议,sql,oracle,sql-insert,Sql,Oracle,Sql Insert,我有以下表格: tb_profile tb_mbx tb_profile_mbx tb_profile_cd id id id_profile id_perfil cod_mat mbx id_mbx id_cd (matches id_mbx) concil bp masc 我需要创建一个查询,当验证
tb_profile tb_mbx tb_profile_mbx tb_profile_cd
id id id_profile id_perfil
cod_mat mbx id_mbx id_cd (matches id_mbx)
concil bp
masc
- 我需要创建一个查询,当验证id_cd 1,2,4,5 如果tb_profile_cd中存在6,则在 tb_profile_mbx表,带有tb_profile的cod_矩阵参数 桌子
- 请记住,每个concil在tb_mbx表中都有其ID,并且 concil有很多商品
- 另一点是concil id_mbx表示 tb\U配置文件\U cd表
- 还有一点是,正如我上面所说,一个礼宾官有很多 鳕鱼垫。每个礼宾部我都有大约两万张唱片
insert into tb_profile_mbx values (seq_profile_mbx.nextval,
(select id from tb_profile where concil like '%NEXXERA%')
,(select id from tb_mbx where mbx like '%NEXXERA%')
,null
,null);
ORA-01427:单行子查询返回多行
是否有其他方法来执行此查询
提前谢谢 您可以使用以下方法插入匹配的所有匹配组合:
insert into tb_profile_mbx (id_profile, id_mbx)
select p.id, m.id
from tb_profile p join
tb_mbx m
on p.concil like '%NEXXERA%' and m.mbx like '%NEXXERA%';
我建议运行select
,查看它是否返回您想要的值
对于
tb\u profile\u mbx
,您只显示了两列,因此我在insert
insert into tb\u profile\u mbx选择seq\u profile\u mbx.nextval,id。。。从tb_profile…
请提供示例数据和所需结果。select正确返回id,但要执行插入,我需要再包含两个始终为空的字段,例如:id_perfil、id_mbx、bp(空)、masc(空)代码>@devnan。在INSERT
中列出列,只需将NULL
添加到SELECT
中的相应位置即可。