有什么方法可以在react-native中使用多个where子句

时间:2019-07-18 19:28:36

标签: sqlite react-native react-native-android

我正在创建一个用户身份验证应用,并且正在尝试使用用户名和密码来获取特定的匹配用户。

我正在尝试这样做。

var Username = this.state.Username;
      var Password = this.state.Password;
      db.transaction(tx =>{
        db.transaction(tx => {
          console.log("Hellow");
          tx.executeSql('SELECT * FROM users WHERE username ? AND password ? ', [Username,Password], (tx, results) => {
            console.log(results);

          });
        });
      });

但是此代码不返回任何内容

1 个答案:

答案 0 :(得分:1)

我用条件号解决了我的问题,我从条件中错过了标志号

示例

   var Username = this.state.Username;
    var Password = this.state.Password;

    db.transaction(tx =>{
      db.transaction(tx => {
        tx.executeSql('SELECT U.userid FROM users AS U WHERE U.username= ? AND U.password = ?; ', [Username,Password], (tx, results) => {
          console.log(results);

        });
      });
    });