开发者

using the AND clause with SQLite and Android

I am trying to fetch a value by comparing two columns but my application crashes every time.

Cursor cursor= db.query(TABLE_IMAGES, 
                        new String[]{"_id"}, 
                        name +" = ?" + time +" = ?", 
               开发者_运维知识库         new String[]{compareToThis, compare to that},  
                        null, null, null);


Try the following:

Cursor cursor= db.query(TABLE_IMAGES, 
                        new String[]{"_id"}, 
                        name +"=? AND " + time +"=?", 
                        new String[]{compareToThis, compareToThat},  
                        null, null, null);

Given that name and time variables are Strings, and compareToThis and compareToThat are the values for the parameters, that should work for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜