sqlite查询返回null

时间:2013-08-10 15:23:16

标签: android sqlite

我有sqlite查询的代码;

public Cursor getTestData() 
     { 
         try 
         { 
             String sql ="select * from tbl_game where status='0' order BY RANDOM() LIMIT 1"; 

             Cursor mCur = mDb.rawQuery(sql, null); 
             if (mCur!=null) 
             { 
                mCur.moveToNext(); 
             } 
             return mCur; 
         } 
         catch (SQLException mSQLException)  
         { 
             Log.e(TAG, "getTestData >>"+ mSQLException.toString()); 
             throw mSQLException; 
         } 
     }

但我不知道为什么会返回一个空值。

当我删除where子句时,它返回一个值。

这是我的表;

id  |   name    |   image   |   description |   status

1   |menard mabunga |   menard  |   Sample only |   0
2   |francis reyes  |   francis |   Test only   |   1

1 个答案:

答案 0 :(得分:0)

status列中的值看起来好像可能是数字,而不是字符串。请尝试使用where status=0(不带引号)。

相关问题