2

I have two tables Alpha_Setting and Beta_View as show below,

Alpha_Setting:

ID ( Sequence )
VIEW_ID
VIEW_TYPE
VIEW_VALUE

Beta_View

ID
VIEW_NAME
VIEW_TYPE
VIEW_CHECK

I would like to insert multiple ID from Beta_View into VIEW_ID in Alpha_Setting, how should I correct my 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');

1 Answer 1

1

Try this way:

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');

or

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'));

I'm not sure which condition with view_name column is good for you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.