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”来确定被接受的答案:)。