我想獲取特定位置的天氣信息。在雅虎YQL組合兩個查詢
現在,我需要調用以獲取它們:第一個將我當前的位置(緯度/經度)翻譯爲WOEID,第二個調用通過使用該WOEID來檢索天氣信息。
我可以結合這兩個查詢嗎?
第一個是: SELECT * FROM yahoo.maps.findLocation其中q = 「LAT,LON」 和GFLAGS = 「R」
第二個是: SELECT * FROM weather.bylocation其中位置= WOEID AND unit ='c'
我想獲取特定位置的天氣信息。在雅虎YQL組合兩個查詢
現在,我需要調用以獲取它們:第一個將我當前的位置(緯度/經度)翻譯爲WOEID,第二個調用通過使用該WOEID來檢索天氣信息。
我可以結合這兩個查詢嗎?
第一個是: SELECT * FROM yahoo.maps.findLocation其中q = 「LAT,LON」 和GFLAGS = 「R」
第二個是: SELECT * FROM weather.bylocation其中位置= WOEID AND unit ='c'
您可以使用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
)
太好了,謝謝! :-) – dmnkhhn 2010-07-14 12:48:03
又見** [如何結合使用YQL多休息查詢?](http://stackoverflow.com/questions/4917144/how-do-i-combine-multiple-rest-queries-using-yql)** – hippietrail 2011-12-20 21:18:14