Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7752249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:45:04+00:00 2026-06-01T11:45:04+00:00

in websql we can request a certain row like this: tx.executeSql(‘SELECT * FROM tblSettings

  • 0

in websql we can request a certain row like this:

tx.executeSql('SELECT * FROM tblSettings where id = ?', [id], function(tx, rs){
    // do stuff with the resultset.
},
function errorHandler(tx, e){
    // do something upon error.
    console.warn('SQL Error: ', e);
});

however, I know regular SQL and figured i should be able to request

var arr = [1, 2, 3];
tx.executeSql('SELECT * FROM tblSettings where id in (?)', [arr], function(tx, rs){
    // do stuff with the resultset.
},
function errorHandler(tx, e){
    // do something upon error.
    console.warn('SQL Error: ', e);
});

but that gives us no results, the result is always empty. if i would remove the [arr] into arr, then the sql would get a variable amount of parameters, so i figured it should be [arr]. otherwise it would require us to add a dynamic amount of question marks (as many as there are id’s in the array).

so can anyone see what i’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:45:06+00:00Added an answer on June 1, 2026 at 11:45 am

    aparently, there is no other solution, than to manually add a question mark for every item in your array.

    this is actually in the specs on w3.org

    var q = "";
    for each (var i in labels)
      q += (q == "" ? "" : ", ") + "?";
    
    // later to be used as such:
    t.executeSql('SELECT id FROM docs WHERE label IN (' + q + ')', labels, function (t, d) {
      // do stuff with result...
    });
    

    more info here: http://www.w3.org/TR/webdatabase/#introduction (at the end of the introduction)

    however, at the moment i created a helper function that creates such a string for me
    might be better than the above, might not, i haven’t done any performance testing.

    this is what i use now

    var createParamString = function(arr){
      return _(arr).map(function(){ return "?"; }).join(',');
    }
    
    // when called like this:
    createparamString([1,2,3,4,5]);  // >> returns   ?,?,?,?,?
    

    this however makes use of the underscore.js library we have in our project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've the following code to select a row.. When I call the function with
In HTML5 webSQL am running SELECT query within a transaction object. Why do i
I had a function that reads displays the contents of the SELECT query coming
I am trying to call a function that SELECTS values from my Web SQL
How I can save an image in Canvas Control to WebSQL? My application is
I am trying to get the value from an inner function. Why is domain
I am using WebSQL for my PhoneGap application it is fine for GingerBread and
I want to created a public database so other extensions can access it, create
There have been a few articles and questions about how to do this but
Since the WebSQL has lost all the support and the development being stopped, how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.