Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.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
Sql 大量插入的建议_Sql_Oracle_Sql Insert - Fatal编程技术网

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表

  • 还有一点是,正如我上面所说,一个礼宾官有很多 鳕鱼垫。每个礼宾部我都有大约两万张唱片

出于我的需要,请尝试查阅以下查询,但Oracle返回了一个错误:

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
中的相应位置即可。