我有两个表格Alpha_Setting
和Beta_View
,如下所示
Alpha_Setting
:
ID ( Sequence )
VIEW_ID
VIEW_TYPE
VIEW_VALUE
Beta_View
ID
VIEW_NAME
VIEW_TYPE
VIEW_CHECK
我想在Beta_View
中将VIEW_ID
中的多个ID插入Alpha_Setting
,我应该如何更正我的SQL
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');
答案 0 :(得分: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
列的哪个条件对你有好处。