问题
I want to get the weather information for a specific location.
Right now, I need to calls to get them: The first one translated my current position (lat/lon) to a WOEID, the second call retrieves the Weather information by using that WOEID.
Can I combine those 2 queries?
The first one is: select * from yahoo.maps.findLocation where q="LAT, LON" and gflags="R"
The second one is: select * from weather.bylocation where location= WOEID AND unit = 'c'
回答1:
You can use sub-selects to join data between different queries.
In your case, you can grab the woeid from the yahoo.maps.findLocation
table and insert that into a query against the weather.bylocation
table as follows:
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
)
来源:https://stackoverflow.com/questions/3222803/combining-two-queries-in-yahoo-yql