2010-07-11 104 views
4

我想获取特定位置的天气信息。在雅虎YQL组合两个查询

现在,我需要调用以获取它们:第一个将我当前的位置(纬度/经度)翻译为WOEID,第二个调用通过使用该WOEID来检索天气信息。

我可以结合这两个查询吗?

第一个是: SELECT * FROM yahoo.maps.findLocation其中q = “LAT,LON” 和GFLAGS = “R”

第二个是: SELECT * FROM weather.bylocation其中位置= WOEID AND unit ='c'

+0

又见** [如何结合使用YQL多休息查询?](http://stackoverflow.com/questions/4917144/how-do-i-combine-multiple-rest-queries-using-yql)** – hippietrail 2011-12-20 21:18:14

回答

3

您可以使用sub-selects在不同查询之间连接数据。

在你的情况,你可以从yahoo.maps.findLocation表抢WOEID并插入到对weather.bylocation表的查询,如下所示:

select * 
from weather.bylocation 
where unit = 'c' and location in (
    select Results.woeid 
    from yahoo.maps.findLocation 
    where q="LAT, LON" and gflags="R" 
    limit 1 
) 
+0

太好了,谢谢! :-) – dmnkhhn 2010-07-14 12:48:03