在YQL中是否有一个选项来限制每个Feed的第一项?

时间:2010-08-09 07:18:19

标签: yql

在YQL查询中,如何仅返回每个Feed的第一项(示例包含2个Feed,但我会有更多)

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'  
) 

我知道尾部选项,但这是在最终结果上设置的,我如何为每个Feed执行此操作

提前致谢

2 个答案:

答案 0 :(得分: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"
);

或者,您只需过滤原始查询,以便只返回每个Feed的一个结果:

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")

答案 1 :(得分: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