1

我试图插入以下内容:

insert into TABLEA select b.ID,..... from TABLEB b where code = 'NL'

问题是 select * from TABLEB where code = 'NL'; 返回超过 1 个值。

无论如何将其限制为1个值?

我试过select min(b.id)但没用

4

2 回答 2

1

据我所知,您只需要插入一个 where code = NL 的实例,即使有多个符合此条件的记录。

如果这是您想要的,请将您的“select *”更改为“select top 1 *”,它只会从您的子查询中提取一条记录。

于 2017-03-14T17:50:23.987 回答
0

在哪里使用rownum = 1

insert into TABLEA select b.ID,..... from TABLEB b where code = 'NL' and rownum = 1

但是你确定要这样做吗?如果它实际上是您想要的第二行怎么办。您可能想弄清楚为什么您的查询返回多个。

于 2017-03-14T17:40:27.467 回答