sql - Multiple sort/filter factors on a Fusion tables query -


i want perform query on google fusion table. let's assume assembling string below variables. works fine if have 1 parameter in var sort_factors. how can add second parameter sort_factors can both (for example) order date descending , limit response 1000 rows?

var base         = 'https://www.googleapis.com/fusiontables/v2/query?',     columns      = 'sql=select+lat,lng,date,username,tripid',             = '+from+xxxxxxxxxxxxxxxxxxx',     sort_factors = '+limit+1000+and+order+by+date+desc',     key          = '&key=xxxxxxxxxxxxxxxxxxx'; 

limit isn't sorting, and wrong there , limit has last clause in sql:

'+order+by+date+desc+limit+1000' 

the order of clauses fixed , has be:

  1. where
  2. group
  3. order
  4. limit

your code seems javascript, better favour , let js handle encoding.

possible approach:

var base = 'https://www.googleapis.com/fusiontables/v2/query',    columns = 'select lat,lng,date,username,tripid',    = 'from fusiontableid',    //apply filter when want    = '',    //group results when want    groupby = '',    orderby = 'order date desc',    limit = 'limit 1000',    key = 'yourapikey',    //do want jsonp-response? add callback-parameter    callback = '&callback=functionname',    //prepare query;    sql = encodeuricomponent([columns, from, where, groupby, orderby, limit].join(' ')),    //prepare url    url = [base, '?sql=', sql, callback, '&key=', key].join('');    //see got  document.body.appendchild(document.createtextnode(url));
body {    font-family: monospace  }

demo using 4 clauses: http://jsfiddle.net/doktormolle/fc47243g/


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -