0

您好,我想根据用户 ID 获取两个日期之间的记录。

我对获取记录的查询:

System.out.println("in data function");
Cursor curCalllog = db.rawQuery("SELECT KEY_ID FROM "+ KK_AIRLINEBOOK + 
" WHERE " + KEY_Bookingdate +  " BETWEEN ?  AND ?", new String[]{startdate, enddate});

请帮助我查询,因为它显示错误-:no such column id 我的查询有什么问题。请帮我。

原木猫

05-07 12:33:41.294: W/System.err(29046): User id : 1
05-07 12:33:41.294: I/System.out(29046): date from7-1-2013 
05-07 12:33:41.304: I/System.out(29046): date to7-7-2013 
05-07 12:33:41.304: W/System.err(29046): on click
05-07 12:33:42.224: I/System.out(29046): uid for history1
05-07 12:33:42.354: I/System.out(29046): in data function
05-07 12:33:42.354: E/SQLiteLog(29046): (1) no such column: KEY_ID
05-07 12:33:42.634: E/AndroidRuntime(29046): FATAL EXCEPTION: main
05-07 12:33:42.634: E/AndroidRuntime(29046): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.raintek.customerhome/com.raintek.customerhome.History}: android.database.sqlite.SQLiteException: no such column: KEY_ID (code 1): , while compiling: SELECT KEY_ID FROM Airline WHERE bookingdate BETWEEN ?  AND ?
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.os.Looper.loop(Looper.java:137)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.app.ActivityThread.main(ActivityThread.java:5041)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at java.lang.reflect.Method.invokeNative(Native Method)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at java.lang.reflect.Method.invoke(Method.java:511)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at dalvik.system.NativeStart.main(Native Method)
05-07 12:33:42.634: E/AndroidRuntime(29046): Caused by: android.database.sqlite.SQLiteException: no such column: KEY_ID (code 1): , while compiling: SELECT KEY_ID FROM Airline WHERE bookingdate BETWEEN ?  AND ?
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
05-07 12:33:42.634: E/AndroidRuntime(29046):    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)

我的桌子

        db.execSQL(" CREATE TABLE " + KK_AIRLINEBOOK + " (" + KEY_SrNo
                + " INTEGER PRIMARY KEY AUTOINCREMENT, " 
                + KEY_ID + " INTEGER , " + KEY_BNAME + " TEXT , "     
                + KEY_Bookingdate
                + " TEXT, " + KEY_Pickupaddress + " TEXT, " + KEY_City
                + " TEXT, " + KEY_AirportType + " TEXT, "+ KEY_Trip + " TEXT, " + KEY_Cabr + " TEXT , "
                + KEY_FlightDate + " TEXT, " + KEY_FlightTime + " TEXT, " + KEY_CabDate
                + " TEXT, " + KEY_PickupTime + " TEXT, " + KEY_TotalSeats
                + " INTEGER, " + KEY_Charges + " INTEGER , "
                + " FOREIGN KEY(srno) REFERENCES KK_REGISTRATION(id));");
4

1 回答 1

0

改变

Cursor curCalllog = db.rawQuery("SELECT KEY_ID FROM "+ KK_AIRLINEBOOK + 
" WHERE " + KEY_Bookingdate +  " BETWEEN ?  AND ?", new String[]{startdate, enddate});

Cursor curCalllog = db.rawQuery("SELECT "+KEY_ID+" FROM "+ KK_AIRLINEBOOK + 
" WHERE " + KEY_Bookingdate +  " BETWEEN ?  AND ?", new String[]{startdate, enddate});

希望您了解问题发生的原因。它正在寻找 KEY_ID 列。不适用于 KEY_ID 包含的值。

查看日志:

Caused by: android.database.sqlite.SQLiteException: no such column: KEY_ID (code 1): , while compiling: SELECT KEY_ID FROM Airline WHERE bookingdate BETWEEN ?  AND ?
于 2013-05-07T12:40:59.330 回答