gpt4 book ai didi

android - android中的多个where子句

转载 作者:IT王子 更新时间:2023-10-29 06:31:09 26 4
gpt4 key购买 nike

String slctsummary = "select   Reminder_Id,Reminder_Type,Reminder_Date,Reminder_Time,Reminder_Alert from Reminder_Main where Car_ID="
+summaryid
+"AND"
+Reminder_Date
+"="
+currentdate1;

Cursor c = sdb.rawQuery(slctsummary,null);

我想要所有满足这两个条件但通过错误的记录。请帮我摆脱困境谢谢...

日志猫错误.........

> 12-17 11:48:05.250: E/AndroidRuntime(1245):
> java.lang.RuntimeException: Unable to start activity
>ComponentInfo{com.curious.solutions.finalautoistdiary/com.curious.solutions.finalautoistdiary.ReminderSummary}:
> android.database.sqlite.SQLiteException: unrecognized token:
> "1ANDReminder_Date17": , while compiling: select
> Reminder_Id,Reminder_Type,Reminder_Date,Reminder_Time,Reminder_Alert
> from Reminder_Main where Car_ID=1ANDReminder_Date17-NOV-2012

最佳答案

在 AND 周围放置一些空格并在 = 之后添加这些“'”

String Reminder_Main="Reminder_Main",Car_ID="Car_ID",Reminder_Date="Reminder_Date"; 
Cursor c = sdb.rawQuery("select Reminder_Id ,Reminder_Type,Reminder_Date,Reminder_Time,Reminder_Alert from " + Reminder_Main
+" where " + Car_ID + " = ? AND " + Reminder_Date + " = ? " , new String[] { summaryid,currentdate1});
c.moveToFirst();
c.moveToFirst();
int summarycount = c.getCount();

如果这还不足以解决问题,请引用这里 https://stackoverflow.com/a/9061437/1503155解决剩下的问题。

关于android - android中的多个where子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13909309/

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