vendredi 18 décembre 2015

Javascript SQLite: SELECT statement with WHERE IN clause

In Javascript SQLite, is there a better way we can execute a SELECT statement with WHERE IN clause? Let's take the following query as an example:

var ids = [1, 5, 10];

function getBranches (ids) {
    db.transaction(function(tx) {

        tx.executeSql('SELECT * FROM Branch WHERE id in ?', [ids], function(tx,results){

            // process results
        });

    });
}

I know we can always format the WHERE IN clause for the ids in a way SQL recognizes it. But I was wondering if there's a nice way to achieve that requirement.

Thanks,

Manoj

Aucun commentaire:

Enregistrer un commentaire