0

I want to Search from Local Storage , What will be the Sqlite Query for Ionic2 for this- What will be the sql query for searching a number from local storage. Something like this- select row_id from mytable where * like '%searched_text%';

 var searchmobile=newvalue
          this.database.executeSql("SELECT mobile_no FROM customer WHERE mobile_no like ?",
            [searchmobile]).then((customerdata) => 
Aditya Kumar
  • 151
  • 2
  • 4

2 Answers2

0

Try concatenating searchmobile like:

 var searchmobile=newvalue
          this.database.executeSql("SELECT mobile_no FROM customer WHERE mobile_no like ?",
            ['%' + searchmobile + '%']).then((customerdata) =>  
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
0

u need to open the database before executing a query

`var searchmobile=newvalue
this.database = new SQLite();
this.database.openDatabase({
        name: "data.db",
        location: "default"
      }).then(() => {
this.database.executeSql("SELECT mobile_no FROM customer WHERE mobile_no like ?",
            [searchmobile]).then((customerdata) =>`
Santosh Kumar
  • 77
  • 2
  • 8