【问题标题】:how to use LIKE in query of react-native-sqlite-storage如何在 react-native-sqlite-storage 查询中使用 LIKE
【发布时间】:2020-03-15 07:54:01
【问题描述】:

我想让每个用户的名字都包含“天使”。这是我的代码

this.DATABASE.transaction(tx => {
  tx.executeSql(
    "SELECT * FROM tblUser WHERE Name LIKE '%?%'",["Angel"],
    (tx, data) => {
      var result = [];
      for (let i = 0; i < data.rows.length; i++) {
        result.push(data.rows.item(i));
      }
    },
})

但我收到错误 "Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters." 它只知道 ? 当它独立时,不理解我的查询。这个问题有解决办法吗?

【问题讨论】:

    标签: react-native-sqlite-storage


    【解决方案1】:

    使用

    "SELECT * FROM tblUser WHERE Name LIKE ?",[`%${Angel}%`]
    

    【讨论】:

      猜你喜欢
      • 2012-06-08
      • 2017-10-31
      • 2019-07-15
      • 2022-08-09
      • 2015-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多