user14696
user14696

Reputation: 677

WHERE query to FusionTables...(GoogleMaps v3)?

I seem to not be understanding the syntax of the WHERE part of the fusion tables query. Trying to create a styles: array (of only 4 styles...).

If I comment out the WHERE part of my query...everything runs...however with the WHERE query -- nothing loads.

Looks like this (note: changed the names, but not the punctuation):

var layer = new google.maps.FusionTables Layer({
    query:{
        select: 'geometry',
        from: 'Encrypted ID'
        where: 'ColumnName' = 'String',
    }

});

I've tried different varieties of this WHERE query with different syntax (notably I have a 'ColumnName' that I can link to a real number).

I am so confused as to where I've gone awry here.... Should I be using ROWID from the Select on the 'geometry' column? Do I have a bad combo of operations and quotes?...Please help if you can.

Many Thanks!!!

Upvotes: 3

Views: 4232

Answers (2)

geocodezip
geocodezip

Reputation: 161334

from the documentation https://developers.google.com/fusiontables/docs/v2/sql-reference

(Original link: https://developers.google.com/fusiontables/docs/v1/sql-reference#Select, updated per comment by douglasg14b)

<column_condition>  
Used in the WHERE clause. The syntax is: <column_name> <operator> <value>

<column_name> is described earlier in this table.

For <operator>, use one of the following with a <number>:

>, <, >=, <=, =
For <operator>, use one of the following with a <string>:

>, <, >=, <=, =
LIKE
MATCHES (equivalent to LIKE)
STARTS WITH
ENDS WITH
CONTAINS
CONTAINS IGNORING CASE
DOES NOT CONTAIN
NOT EQUAL TO
IN

I would suggest not using <, <, >=, <=, = with strings; while the documentation says you can, I have found it problematic. You also need to use single quotes around strings and column names with spaces.

Upvotes: 2

sanya
sanya

Reputation: 890

Your WHERE clause is faulty.

Here's the proper one:

where: "'ColumnName' = 'String'",

and BTW you should always check your javascript error console first if something is not working...

Upvotes: 4

Related Questions