Where子句中的多个条件

Where子句中的多个条件

本文介绍了样式中忽略了Fusion Table Layer Where子句中的多个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写的是关于我的一个较早的问题的,该问题也与Google Maps中Fusion Table Layer的Where子句的使用有关. 链接到先前的问题.已经注意到,如果样式"部分中的"Where"子句中包含多个过滤条件,则将其完全忽略.然后,Google Map/Fusion Tables图层最终将该样式应用于该Fusion表中包含的所有要素.您可以从Where子句中删除一个过滤条件,使其成为单个过滤器where子句,然后按预期方式工作,因此,我很确定它不喜欢SAME where子句中的多个过滤条件(或我的方式)编写).

I am writing with reference to an earlier question of mine, which also had to do with the use of Where clauses for Fusion Table Layer in Google Maps. Link to earlier question. I have noticed that if the Where clause in Styles section has more than one filtering conditions in it, it is ignored altogether. Google Map/Fusion Tables Layers then ends up applying that Style to ALL of the features contained in that Fusion table. You can remove a filtering condition from the Where clause to make it a single filter where clause, and it then works as expected so I am pretty sure that it doesn't like multiple filtering condition in the SAME where clause (or the way I am writing it).

以下是说明此行为的示例:

Here is an example that illustrates this behavior:

    layer = new google.maps.FusionTablesLayer({
  map: map,
  options: {
    templateId: 2
  },
  heatmap: { enabled: false },
  query: {
    select: "geometry",
     from: "1D6d93-0iT2zUCw8IvkbpDPYDx2-jA0ZAWXi07mQD",
  },
        styles: [{

          //note multiple filters in the same Where clause.

          where: "((SHIFT_ID != 1) AND (SHIFT_ID != 2))",

          //you'd expect the following Style option applied to only those map features
          //which met above criteria. However, they are applied to ALL map features.

          polylineOptions: {
            strokeOpacity: 0.70,
            strokeColor: "#FFFFFF",
            strokeWeight: "5"  }

     //if Where clause is reduced to just having one filter, it works fine.
     //For example, either of the following two work fine by themselves.
     //where: "SHIFT_ID != 1"   --OR--
     //where: "SHIFT_ID != 2"    etc.

        }]
});

推荐答案

Geocodezip是正确的;查询无效.

Geocodezip was right; query was invalid.

这就是我能够确定对Fusion Tables的查询重用的原因.

This is what I have been able to determine re use of queries for Fusion Tables.

  1. 在一个where子句中可以有多个字段/过滤器.
  2. 不能将方括号()"用于布尔逻辑.
  3. 使用!NOT EQUAL TO代替!=
  4. 对于NULL值,请检查是否与''(空字符串)相等.
  5. 字段名称区分大小写.

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

这篇关于样式中忽略了Fusion Table Layer Where子句中的多个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 21:35