SQLite搜索查询

时间:2017-04-16 10:53:49

标签: sqlite ionic2

我想从本地存储中搜索,Ionic2的Sqlite查询对于此 - 从本地存储中搜索数字的sql查询是什么。 像这样的东西 - 从mytable中选择row_id,其中* like'%searching_text%';

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

2 个答案:

答案 0 :(得分:0)

尝试连接searchmobile,如:

 var searchmobile=newvalue
          this.database.executeSql("SELECT mobile_no FROM customer WHERE mobile_no like ?",
            ['%' + searchmobile + '%']).then((customerdata) =>  

答案 1 :(得分:0)

你需要在执行查询之前打开数据库

`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) =>`