Reputation: 1125
I am new to DBFLow. I want to make aquery that returns one row depending on a where clause..I seem not to find a where clause with an and.
String phone = uname_pass[0];
String pass = uname_pass[1];
List<User> userList = SQLite.select().from(User.class).where("phone ?",phone ).execute();
I want to retrieve where phone = uname_pass[0];
and password = uname_pass[1]
;
What could be the right query ?
Upvotes: 0
Views: 662
Reputation: 480
1) Synchronous:
List<User> userList = SQLite.select()
.from(User.class)
.where(User_Table.phone.eq(uname_pass[0], User_Table.password.eq(uname_pass[1]))
.queryList();
Also you can write it like that (with ".and" in this case. You can choose ".or" and other operators instead of ".and")
List<User> userList = SQLite.select()
.from(User.class)
.where(User_Table.phone.eq(uname_pass[0]))
.and(User_Table.password.eq(uname_pass[1]))
.queryList();
2) Asynchronous:
SQLite.select()
.from(User.class)
.where(User_Table.phone.eq(uname_pass[0]),User_Table.password.eq(uname_pass[1]))
.async()
.queryListResultCallback(new QueryTransaction.QueryResultListCallback<User>() {
@Override
public void onListQueryResult(QueryTransaction transaction, List<User> tResult) {
//your list will be tResult
}
}).execute();
Upvotes: 1