2

在 YQL 查询中,我如何只返回每个提要的第一项(例如有 2 个提要,但我会有更多)

select channel.title,channel.link,channel.item.title,channel.item.link  
from xml where url in(  
  'http://code.flickr.com/blog/feed/rss/',  
  'http://www.quirksmode.org/blog/index.xml'  
) 

我知道 tail 选项,但它是在最终结果上设置的,我如何在每个提要中执行此操作

提前致谢

4

2 回答 2

4

您可以使用该yql.query.multi表进行多个查询,例如:

select *
from yql.query.multi where queries in (
    "select channel.title,channel.link,channel.item.title,channel.item.link from xml where url='http://code.flickr.com/blog/feed/rss/' limit 1",
    "select channel.title,channel.link,channel.item.title,channel.item.link from xml where url='http://www.quirksmode.org/blog/index.xml' limit 1"
);

或者,您可以只过滤原始查询,以便每个提要仅返回一个结果:

select channel.title,channel.link,channel.item.title,channel.item.link  
from xml where url in(  
    'http://code.flickr.com/blog/feed/rss/',  
    'http://www.quirksmode.org/blog/index.xml'  
 ) | unique(field="channel.link")
于 2010-08-09T08:15:57.293 回答
0

通过在末尾添加LIMIT 1

select channel.title,channel.link,channel.item.title,channel.item.link  
from xml where url in(  
  'http://code.flickr.com/blog/feed/rss/',  
  'http://www.quirksmode.org/blog/index.xml'  
) LIMIT 1
于 2010-08-09T07:21:36.960 回答