开发者

using the AND clause with SQLite and Android

开发者 https://www.devze.com 2023-02-27 04:11 出处:网络
I am trying to fetch a value by comparing two columns but my application crashes every time. Cursor cursor= db.query(TABLE_IMAGES,

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

精彩评论

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