2

我有两张桌子Alpha_SettingBeta_View如下所示,

Alpha_Setting

ID ( Sequence )
VIEW_ID
VIEW_TYPE
VIEW_VALUE

Beta_View

ID
VIEW_NAME
VIEW_TYPE
VIEW_CHECK

我想从in 中Beta_View插入多个 ID ,我应该如何更正我的 SQLVIEW_IDAlpha_Setting

insert into alpha_setting 
('',  
(select ID from beta_view where view_type = 'HERO' and (view_name = 'GREEN-All' or view_name = 'GREEN-New'),  
'super_power',   
'1000000');
4

1 回答 1

1

试试这个方法:

insert into alpha_setting (ID,VIEW_ID,VIEW_TYPE,VIEW_VALUE)
select '' /* or seq_name.nextval*/, ID,'super_power','1000000'
from beta_view 
where view_type = 'HERO' 
and view_name in('GREEN-All','GREEN-New','super_power','1000000');

或者

insert into alpha_setting (ID,VIEW_ID,VIEW_TYPE,VIEW_VALUE)
select '' /* or seq_name.nextval*/, ID,'super_power','1000000'
from beta_view 
where view_type = 'HERO' 
and (view_name = 'GREEN-All' or view_name in('GREEN-New','super_power','1000000'));

我不确定哪个条件与view_name列对你有好处。

于 2013-08-20T20:30:41.183 回答