Android Sqlite查询语法查询错误。需要帮助

时间:2017-07-07 08:58:38

标签: android sqlite android-sqlite

请检查我的语法并纠正我..

收到错误  引起:android.database.sqlite.SQLiteException:接近“BETWEEN30”:语法错误(代码1):,同时编译:SELECT * FROM TABLE_ITEMS WHERE date BETWEEN30 / 06 / 2017'AND'07 / 07/2017'

 String query = " SELECT * FROM " + TABLE + " WHERE date BETWEEN" + past_date + "'AND'" + current_date + "' " ;

1 个答案:

答案 0 :(得分:1)

  

SQLite异常,指示SQL解析时出错   或执行。

使用 BLANK SPACE &amp ;;来纠正您的陈述 Single-Double 字符

String query = " SELECT * FROM " + TABLE_ITEMS + " WHERE date BETWEEN " + past_date + " AND " + current_date + "  ;

您可以尝试使用

 "SELECT * FROM " + TABLE_NAME+ " WHERE  date "+ BETWEEN past_date('"+DATE_STR_FORMAT+"') + " AND current_date " ('"+DATE_STR_FORMAT_CURRENT+"')"";