Search code examples
mysqlgoogle-fusion-tableslinechart

Filter Fusion Table Query With WHERE Clause


I have a fusion table with three columns of numeric data. The first column is a four digit year beginning in 1843 and ending in 2016. The next two columns are a count of events (births & marriages) for the corresponding year ranging from 0 to 16,100. All three columns contain numbers with no formatting.

My query displays a count of events by year in a line chart. Because of the limitations of publication there are no records of births public after 1914, so I don't want to include years after 1914 even if there are records in the database.

If I remove the WHERE 'Year' BETWEEN 1843 AND 1914 clause from the query the linechart will display. With the WHERE clause it shows "Data table is not defined."

I know one workaround would be to query a different spreadsheet that only contains the data for the years I want, but that won't help me to learn why what I've been trying won't work.

Any help is appreciated.

I can get this SQL to work in other applications, but not with the Fusion table.

var query = "SELECT 'Year', 'Birth' FROM 1yBq_Zz3iPsK3U49NIp-yc5uXVrato3hKXxqsjyzk WHERE 'Year' BETWEEN 1843 AND 1915 ORDER BY 'Year'" ;

Solution

  • There is no BETWEEN operator in Google Fusion Tables API. You should use AND instead.

    Something like this

    "SELECT 'Year', 'Birth' FROM 1yBq_Zz3iPsK3U49NIp-yc5uXVrato3hKXxqsjyzk WHERE 'Year' >= 1843 AND 'Year' <= 1915 ORDER BY 'Year'"

    Check Querying for data.