2
insert into p_article_client_detail_current(article_id,sector_detail_id)
select article_id,2818
from ( select article_id from p_article_client_detail_current
       where sector_detail_id=239 and convert(varchar(11),feed_date,101) >= '12/07/2012'
)

消息 102,级别 15,状态 1,第 5 行 ')' 附近的语法不正确

这个查询有什么问题,请帮忙。

4

3 回答 3

6

尝试添加表名(例如T),如下所示:

insert into p_article_client_detail_current(article_id,sector_detail_id)
select article_id,2818
from ( select article_id from p_article_client_detail_current
       where sector_detail_id=239 and convert(varchar(11),feed_date,101) >= '12/07/2012'
) T

如果您不需要嵌套查询,您也可以使用此查询:

insert into p_article_client_detail_current(article_id,sector_detail_id)
select article_id,2818
from p_article_client_detail_current
where sector_detail_id=239 
and convert(varchar(11),feed_date,101) >= '12/07/2012'
于 2012-12-11T08:10:47.407 回答
2
insert into p_article_client_detail_current(article_id,sector_detail_id)
select article_id,2818 from p_article_client_detail_current
where sector_detail_id=239 and convert(varchar(11),feed_date,101) >= '12/07/2012'
于 2012-12-11T08:15:23.783 回答
1

请为您从中插入数据的源插入别名。

insert into p_article_client_detail_current(article_id,sector_detail_id)
select article_id,2818
from ( select article_id from p_article_client_detail_current
       where sector_detail_id=239 and convert(varchar(11),feed_date,101) >= '12/07/2012'
) as tablealias
于 2019-03-07T06:51:14.677 回答