简体   繁体   中英

Multiple Where clause in Android SQL statement

I am having some problem with the SQL statement for Android. Basically I have two where clause, bookID and userID and the SQL statement that I am having now:

public boolean updateLoan(String bookID, String userID, String currentDate) {
    try {
        ContentValues cv = new ContentValues();
        cv.put("loanDate", currentDate);

        mDb.update("loanBook", cv,
                " bookID= '" + bookID + "'", null);

        return true;
    } catch (Exception ex) {
        Log.e(TAG, ex.toString());
        return false;
    }
}

So I wonder how could I put two where clause in this method as currently I only can where clause by bookID. Do I simply put an "&" and continue the SQL statement?

Thanks in advance.

Do I simply put an "&" and continue the SQL statement?

Yes, use AND instead of &

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM