0

I am trying to grab weather data via Yahoo YQL, here is the query below, my question is how can I query these locations only found in the United States? I tried adding AND country = "US" or place = "United States", but that returns no results. I want to only search the US because when searching for example Danville, CA it brings up 2 results, 1 from the US and 1 from Canada. Any suggestions? Thanks!

                    SELECT
                      *
                    FROM
                      weather.forecast
                    WHERE
                      woeid
                    IN
                    (
                      SELECT
                        woeid
                      FROM
                        geo.places
                      WHERE
                        text
                      IN("Danville, CA","Sunnyvale, CA")
                    )
                    AND
                      u="f"
John
  • 9,840
  • 26
  • 91
  • 137

1 Answers1

0

Looks like I posted too soon. There are 2 ways I was able to resolve this.

First Solution:

I was adding the Country = "United States" to the wrong part of the query. I was adding it after AND u="f", it worked when I added it to the sub query as so:

SELECT woeid FROM geo.places WHERE text IN("Danville, CA","Sunnyvale, CA") AND country = "United States"

Second Solution:

This is the solution I am going with as it resolves my issue if by chance I need to search outside of the United States and easier to implement. Instead of searching by City, State, I simply add the country code to the query as so:

SELECT woeid FROM geo.places WHERE text IN("Danville, CA US","Sunnyvale, CA US")

That way if I need to search in a different country, I can simply edit the individual text search instead of binding all searches to the US.

John
  • 9,840
  • 26
  • 91
  • 137