基于SELECT语句INSERT多行

时间:2016-08-18 10:49:22

标签: sql sql-server-2008

我正在使用SQL Server 2008,在其他线程的帮助下,我已经能够编写以下内容:

insert into fml0grant (auto_key, roleid)
    select fml0.auto_key, 20 
    from fml0
    left join fml0grant on fml0.auto_key = fml0grant.auto_key
    where fml0.dwgname <> ''
      and fml0grant.roleid is null

但是,我需要做的是为wh​​ere子句中的每条记录插入多行。所以当where子句得到结果时我需要插入:

  1. fml0.auto_key,20
  2. fml0.auto_key,508
  3. fml0.auto_key,10
  4. 有没有办法将所有三个插入组合成一个语句,因为在我的查询中第一个后,WHERE子句中的NULL不再为真。

1 个答案:

答案 0 :(得分:1)

您可以使用mapStateToProps(state),如下所示。

CROSS JOIN
相关问题