tags:

views:

19

answers:

2

Hi

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

A: 

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
Codler
No, LIMIT 1 limits the final resultset, I want to have the first item of each feed, now it just returns the first item of the combined feeds.
nokiko
+2  A: 

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