融合表查询位置 [英] fusiontable query for where

查看:87
本文介绍了融合表查询位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以动态地根据用户输入生成条件.我有一个选择框,其中包含选项'>','<','等于','以'开始','以'结束'.这种情况下应该生成where子句并应该执行查询.请帮助我.我需要示例. 由于我的表中大约有80列,因此无法使用if else循环.

Is there any way to generate where condition based on user input dynamically.I have a select box with the option '>','<','equals','starts with','ends with'.Based on this condition where clause should be generated and query should be executed.Please help me.i need examples. since i have around 80 columns in my table i cant use if else loop.

function querymap()


{
var querypass=document.getElementById('query-pass').value.replace(/'/g, "\\'");
 if(querypass=='hhSanitHouseType')
   {
     var operator=document.getElementById('operatorstring').value.replace(/'/g, "\\'");
     if(operator=='>')
        { 
          var textvalue=document.getElementById("text-value").value.replace(/'/g, "\\'");
          layer.setQuery("SELECT 'geometry',hhSanitHouseType FROM " + tableid + " WHERE 'hhSanitHouseType' > '" + textvalue + "'");


        }
     }
   else
   {
   alert("false");
   }
}

推荐答案

也许您可以检查该示例,尤其是函数generateWhere(columnName, low, high).

Maybe you can check this example, especially the function generateWhere(columnName, low, high).

您不必为运算符使用if/else,只需检查输入是否有效(即运算符是'>','<','等于','以'开头','以')结尾,然后将其直接传递到您的查询中,诸如此类

You don't have to use if/else for your operator, just check for a valid input (i.e. that the operator is one of '>','<','equals','starts with','ends with') and then pass it directly to your query, something like that

 var operator = ...;
 var textvalue = ...;
 layer.setQuery("SELECT 'geometry',hhSanitHouseType FROM " + tableid + " WHERE 'hhSanitHouseType'" + operator + " '" + textvalue + "'");

这篇关于融合表查询位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆