【问题标题】:Oracle SQL Insert statement for multiple tables多个表的 Oracle SQL 插入语句
【发布时间】:2013-08-20 20:28:41
【问题描述】:

我有两张表 Alpha_SettingBeta_View 如下所示,

Alpha_Setting:

ID ( Sequence )
VIEW_ID
VIEW_TYPE
VIEW_VALUE

Beta_View

ID
VIEW_NAME
VIEW_TYPE
VIEW_CHECK

我想将Beta_View中的多个ID插入Alpha_Setting中的VIEW_ID,我应该如何更正我的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');

【问题讨论】:

    标签: sql database oracle sql-insert


    【解决方案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 列的哪个条件适合您。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多