gpt4 book ai didi

sql - 发生错误 : "Cannot call methods on nvarchar."

转载 作者:行者123 更新时间:2023-12-04 23:47:19 28 4
gpt4 key购买 nike

我写了一个查询来查找与特定问题相关的答案,但在运行此代码时收到此错误。

Cannot call methods on nvarchar


 select Posts.Id as Answer, ParentId as question, User.DisplayName as Answerer 
FROM Posts
INNER JOIN Users ON Posts.OwnerUserId = Users.Id
WHERE
ParentId in (SELECT Posts.Id
FROM Posts
INNER JOIN PostTags ON Posts.Id = PostTags.PostId
INNER JOIN Tags ON PostTags.TagId = Tags.id
INNER JOIN Users ON Posts.OwnerUserId = Users.id
INNER JOIN PostTypes ON Posts.PostTypeId = PostTypes.Id
WHERE Tags.TagName in
(select
num.TagName as Tag

from

(select TagName
from
Tags, PostTags, Posts
where Tags.Id = PostTags.TagId and Posts.Id = PostId
and Posts.CreationDate < '2015-04-20'
and Posts.CreationDate > '2015-01-01'
group by TagName) as rate

INNER JOIN
(select TagName
from Tags, PostTags, Posts
where Tags.Id = PostTags.TagId and Posts.Id = PostId
group by TagName
having count(PostId) > 8000)as num
ON rate.TagName = num.TagName
)
AND Posts.AnswerCount > 1
AND Posts.AcceptedAnswerId is not null
AND Posts.Score > 0
AND Posts.PostTypeId = 1 -- PostTypeId = 1 -> Question
AND Posts.CommunityOwnedDate is null
)
AND Posts.PostTypeId = 2 -- -> Answers

我认为问题是 ParentId ,但我不明白有什么问题。

最佳答案

您有保留字 User在您的查询中:

select Posts.Id as Answer, ParentId as question, User.DisplayName as Answerer



您需要将其修改为 [User].DisplayName
以下是有关 SQL 中保留字的重要资源: https://www.drupal.org/node/141051

关于sql - 发生错误 : "Cannot call methods on nvarchar.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29853631/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com