How do u write query with condition "LIKE", For example,
I would like to make select few rows where my word colomn rows matches with word_name
normally would like this,
"SELECT rowid AS word_id,word from table WHERE word LIKE '%word_name%' "
using this plugin, in my JS file , i am trying to do like this,
var query = ""SELECT rowid AS word_id,word from table WHERE word LIKE '%(?)%' ""
$cordovaSQLite.execute(DBname, query, [word_name]).then(function(res) {
});
But this does not work ? any help ??
var query = ""SELECT rowid AS word_id,word from table WHERE word LIKE '%(?)%' "" $cordovaSQLite.execute(DBname, query, [word_name]).then(function(res) { });
First, you have too many double-quote marks in the query string. Second, I found a nice tip how to do this with the Web SQL API here: http://stackoverflow.com/a/17963259
Following that answer, I would suggest you try something like this:
var query = "SELECT rowid AS word_id,word from table WHERE (word LIKE ?)";
$cordovaSQLite.execute(DBname, query, ['%'+word_name+'%']).then(function(res) {
});
Most helpful comment
First, you have too many double-quote marks in the query string. Second, I found a nice tip how to do this with the Web SQL API here: http://stackoverflow.com/a/17963259
Following that answer, I would suggest you try something like this: