gpt4 book ai didi

java - 需要有关 android sql 查询的帮助

转载 作者:行者123 更新时间:2023-12-01 15:45:56 26 4
gpt4 key购买 nike

我有一个错误

     String currentDateTimeString = DateFormat.getDateInstance().format(new Date());

Cursor myCursor=db.query(true, DATABASE_TABLE, new String[]{KEY_ROWID,MONEY_FIGURE,SPENDING_DETAILS,DATE}
, KEY_ROWID , null, null, DATE+"="+currentDateTimeString, KEY_ROWID, null);

androids api的查询函数:

query(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)

我在这里想做的是说。根据日期等于的位置给我所有数据当前日期时间字符串。

但是我在该声明中收到错误..不要问我错误是什么..当我删除对保存该查询语句的方法的调用时,错误不会出现..所以我猜这是一个sqlexception

解决了我的问题:

 Cursor myCursor=db.query(true, DATABASE_TABLE, new String[]{KEY_ROWID,MONEY_FIGURE,SPENDING_DETAILS,DATE}
,DATE+"='"+currentDateTimeString+"'" , null, null, null , KEY_ROWID, null);

我正在尝试这样做

SELECT MONEY_FIGURE,SPENDING_DETAILS,DATE
FROM SpendingManagmentTable
WHERE Date=@ currentDateTimeString

最佳答案

如果列类型不是数字,则必须与 '' 一起使用

日期='1/1/2011'而不是日期=1/1/2011

Cursor c =  db.query(DATABASE_TABLE, new String[] {{KEY_ROWID,MONEY_FIGURE,SPENDING_DETAILS,DATE},DATE+"='"+currentDateTimeString+"'", null, null, null, null);

关于java - 需要有关 android sql 查询的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7006821/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com