Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where "not null" clause in sqlite android

I want to retrieve notes from database where notes are (not null), I wrote the following code:

public Cursor getmynotesss(int id){
    Cursor mCursor = database.query(true, NOTES_TABLE, new String[] {
            NOTE_TEXT, PAGE_NO,BOOK_ID},BOOK_ID + "=? AND "+NOTE_TEXT+" IS NOT NULL OR "+NOTE_TEXT+" != ''" ,
            new String[] { String.valueOf(id) }, null, null, null, null);

    if (mCursor != null) {
        mCursor.moveToFirst();
    }
    return mCursor;
}

but it still gives me the null notes. what is the wrong in my code?

like image 396
user1553381 Avatar asked Jan 27 '26 23:01

user1553381


1 Answers

It looks like the OR condition should be AND :

"=? AND "+NOTE_TEXT+" IS NOT NULL AND "+NOTE_TEXT+" != ''"
like image 160
Dalmas Avatar answered Jan 30 '26 17:01

Dalmas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!