Google Fusion Table 的复杂 SQL 查询出现问题。我可以在查询中使用外部值吗?

Trouble with a complicated SQL query for Google Fusion Table. Can I use external values within my query?

这个项目的基本轮廓是它是伦敦区之间旅行时间的视觉表示。

到目前为止,我已经设置了一个 google 融合 table,它可以很好地响应基本查询。但现在我正在尝试根据行程时间 to/from 一个选定的多边形 table 改变我的融合 table 多边形的颜色。

function fillcolour(match) {
  var limit = 0;
  var filter = [];

  for (x in match) {
    if (limit < 5) {
      var duration = match[x];
      if (dataraw[1]) {
          //-------75 and 65 are stand in values at the moment. They will later be filled by variables.
          filter.push("(" + generateWhere(x, duration, 75, 65) + ")");
      }
      limit++;
    }
  }
  where = filter.join(' OR ');

  PolygonLayer.setOptions({
    query: {
      select: 'shape',
      from: mapTable
    },
    styles: [{
      polygonOptions: {
        fillColor: "#000FFF",
        fillOpacity: .8
      }
    },
    {
      where: where,
      polygonOptions: {
        fillColor: "#FFF000"
      }
    }],
  })
};

function generateWhere(Keys, duration, high, low) {
  var whereClause = [];
  whereClause.push("name");
  whereClause.push(" = '");
  whereClause.push(Keys);
  whereClause.push("' AND ");
  whereClause.push(duration);
  whereClause.push(" >= ");
  whereClause.push(low);
  whereClause.push(" AND ");
  whereClause.push(duration);
  whereClause.push(" < ");
  whereClause.push(high);
  return whereClause.join('');
}

我知道可能有更简单的方法来处理多边形选项,但目前我的 SQL 查询没有按我希望的方式运行。

这是被输入 where 语句的查询:

(name = 'Abbey Wood' AND 80 >= 65 AND 80 < 75) OR (name = 'Acton' AND 74 >= 65 AND 74 < 75) OR (name = 'Anerley' AND 46 >= 65 AND 46 < 75)

有谁知道为什么这不起作用?

(name = 'Abbey Wood' AND 80 >= 65 AND 80 < 75) OR (name = 'Acton' AND 74 >= 65 AND 74 < 75) OR (name = 'Anerley' AND 46 >= 65 AND 46 < 75)

查询有两个问题

1) Fusion Table Queries:

"You must use quotes around any column names in the select or where fields that contain spaces, reserved words, or that do not begin with a letter".

2) Row and Query SQL Reference:

"OR is not supported."

因此您需要添加引号并将 OR 子查询拆分为单独的查询

styles: [{
    polygonOptions: {
        fillColor: "#000FFF",
        fillOpacity: .8
    }
},
{
    where: "name = 'Abbey Wood' AND '80' >= 65 AND '80' < 75",
    polygonOptions: {
        fillColor: "#FFF000"   
    }
},
{
    where: "name = 'Acton' AND '74' >= 65 AND '74' < 75",
    polygonOptions: {
        fillColor: "#FFF000"    
    }
},
{
    where: "name = 'Anerley' AND '46' >= 65 AND '46' < 75",
    polygonOptions: {
        fillColor: "#FFF000"    
    }
}]