Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.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,我正在尝试插入多行,其中每行具有相同的环境\u id,但它具有不同的属性\u id。类似于以下内容: INSERT INTO appserver_prop (environment_id, property_id) VALUES (497, select property_id from prop_info where property_name like '%CPNIB%') 我想你需要插入。选择: insert into appserver_prop (environment_id, pr

我正在尝试插入多行,其中每行具有相同的
环境\u id
,但它具有不同的
属性\u id
。类似于以下内容:

INSERT INTO appserver_prop (environment_id, property_id)
VALUES (497, select property_id from prop_info where property_name like '%CPNIB%')

我想你需要
插入。选择

insert into appserver_prop (environment_id, property_id)
    select 497, property_id
    from prop_info
    where property_name like '%CPNIB%';

我想你需要
插入。选择

insert into appserver_prop (environment_id, property_id)
    select 497, property_id
    from prop_info
    where property_name like '%CPNIB%';
只需使用:

insert into appserver_prop(environment_id, property_id)
select 497, property_id from prop_info where property_name like '%CPNIB%'
您不需要
values
子句,因为您不想在SQL中插入单个记录,而是要插入多个记录集。

只需使用:

insert into appserver_prop(environment_id, property_id)
select 497, property_id from prop_info where property_name like '%CPNIB%'

您不需要
values
子句,因为您不是要在SQL中插入单个记录,而是要插入多个记录集。

@Robin-最好将其中一个答案标记为正确答案。在这种情况下,两个相同的答案几乎同时发布。Gordon的答案似乎是第一个(几秒钟后),所以它可能会得到正确的答案。@mathguy我用“ini mini miny moe”来确定被接受的答案:)。@Robin-你最好将其中一个答案标记为正确答案。在这种情况下,两个相同的答案几乎同时发布。Gordon的答案似乎是第一个(几秒钟后),所以它可能会得到正确的答案。@mathguy我用“ini mini miny moe”来确定被接受的答案:)。