【发布时间】:2016-08-18 19:00:09
【问题描述】:
我正在使用 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
但是,我需要为 where 子句中找到的每条记录插入多行。所以当 where 子句得到结果时,我需要插入:
- fml0.auto_key, 20
- fml0.auto_key, 508
- fml0.auto_key, 10
有没有办法将所有三个插入组合到一个语句中,因为在我的查询中的第一个语句之后,WHERE 子句中的 NULL 不再为真。
【问题讨论】:
-
这个问题我不清楚,请看here如何改进问题..
标签: sql sql-server-2008