Question

In an YQL query how do I return only the first item of each feed ( example with 2 feeds but i will have more )

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

I know of the tail option but that is set over the final result, how can i do this per feed

thanks in advance

Was it helpful?

Solution

You could make multiple queries using the yql.query.multi table like:

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

Or, you could just filter your original query such that only one result from each feed is returned:

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

OTHER TIPS

By adding LIMIT 1 at the end

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top