简体   繁体   English

SODE 查询不返回任何行

[英]SODE query returns no rows

I have the following query on https://data.stackexchange.com/stackoverflow我在https://data.stackexchange.com/stackoverflow上有以下查询

SELECT TOP 10 * FROM Posts
WHERE PostTypeId = 2 
  AND CreationDate > '2022-05-06'
  AND CommentCount = 3
  AND Tags LIKE '%php%'
ORDER BY CreationDate DESC

I am trying to get answers that were posted today in the tag that also have 3 comments.我正在尝试获取今天发布在标签中的答案,该标签也有 3 条评论。

But all I receive is:但我收到的只是:

0 rows returned in 51274 ms 0 行在 51274 毫秒内返回

I'm sure that SE Data Explorer is not always up to date, but the problem seems to be elsewhere.我确信 SE Data Explorer 并不总是最新的,但问题似乎出在其他地方。
The column Tags is null for answers.答案的列Tagsnull
If you want to get the tags you must query the question which you can get by the column ParentId .如果要获取标签,则必须查询可以通过ParentId列获取的问题。

Use a self join:使用自联接:

SELECT TOP 10 p1.* 
FROM Posts p1 INNER JOIN Posts p2
ON p2.Id = p1.ParentId
WHERE p1.PostTypeId = 2 
  AND p2.Tags LIKE '%php%' 
  AND p1.CommentCount = 3
  -- AND <your date condition here>
ORDER BY p1.CreationDate DESC

See the demo .请参阅演示

First, your query seems extremely selective.首先,您的查询似乎极具选择性。 Give me all the answers to PHP questions from today where the answer has exactly 3 comments?从今天起,给我所有 PHP 问题的答案,其中答案正好有3 条评论? I don't know that you're ever going to find a whole lot of those.我不知道你会找到很多这样的东西。 Maybe if you change your criteria to CommentCount >= 3 (and go after tags the right way), but even with those fixes, comments on answers don't often get that high (or stay around very long).也许如果您将您的标准更改为CommentCount >= 3 (并以正确的方式跟踪标签),但即使进行了这些修复,对答案的评论通常不会那么高(或停留很长时间)。

Second, SEDE is updated weekly, on Sundays.其次,SEDE每周日更新。 See this question , this question (which links to this query , which you can use to monitor status), and this question .请参阅这个问题这个问题(链接到这个查询,您可以使用它来监控状态)和这个问题 (It happened to be that just this weekend, the normal refresh failed , but that wouldn't have contributed to this specific issue.) (恰好就在这个周末,正常刷新失败,但这不会导致这个特定问题。)

The SEDE refresh is an extensive operation because the data is transformed in various ways (the structure is simplified to make your queries easier, and the data is sanitized to remove any PII). SEDE 刷新是一项广泛的操作,因为数据以各种方式进行转换(结构被简化以使您的查询更容易,并且数据被清理以删除任何 PII)。 So on a Saturday, no, you're not going to find any posts there from today (well, after the prior Sunday).所以在星期六,不,从今天起你不会在那里找到任何帖子(嗯,在前一个星期天之后)。

You can just check this query to see why your WHERE clause is additionally too selective:你可以检查这个查询,看看为什么你的WHERE子句过于选择性:

SELECT MAX(CreationDate) FROM Posts;

Once you've picked date criteria that work, you can fix the other issues in the query.选择有效的日期条件后,您可以修复查询中的其他问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM