I'm getting a no such column: _id error. YES there is a column "_id" in my journals table.
I'm getting the error with this code:
mDb.execSQL("UPDATE "+DATABASE_PLANTS_TABLE+" SET "+ KEY_PLANT_DAYS+ " = (SELECT COUNT(*) FROM "+DATABASE_PLANTS_TABLE+" WHERE " +DATABASE_JOURNAL_TABLE+"."+KEY_JROWID+" = "+DATABASE_PLANTS_TABLE +"." +KEY_PLANT_HOMEID+")");
The following code DOES work:
mDb.execSQL("UPDATE "+DATABASE_JOURNAL_TABLE+" SET "+KEY_JOURNAL_PLANTS+ " = (SELECT COUNT(*) FROM "+DATABASE_PLANTS_TABLE+" WHERE " +DATABASE_JOURNAL_TABLE+"."+KEY_JROWID+" = "+DATABASE_PLANTS_TABLE +"." +KEY_PLANT_HOMEID+")");
LogCat:
08-21 00:07:46.614: ERROR/Database(12943): Failure 1 (no such column: journals._id) on 0x421470 when preparing 'UPDATE plants SET days = (SELECT COUNT(*) FROM plants WHERE journals._id = plants.homeid)'. 08-21 00:07:46.614: DEBUG/AndroidRuntime(12943): Shutting down VM 08-21 00:07:46.614: WARN/dalvikvm(12943): threadid=3: thread exiting with uncaught exception (group=0x4001b390) 08-21 00:07:46.614: ERROR/AndroidRuntime(12943): Uncaught handler: thread main exiting due to uncaught exception 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.growjournal.beta/com.grower.beta.plantsList}: android.database.sqlite.SQLiteException: no such column: journals._id: UPDATE plants SET days = (SELECT COUNT(*) FROM plants WHERE journals._id = plants.homeid) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at android.app.ActivityThread.access$2200(ActivityThread.java:126) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at android.os.Handler.dispatchMessage(Handler.java:99) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at android.os.Looper.loop(Looper.java:123) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at android.app.ActivityThread.main(ActivityThread.java:4595) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at java.lang.reflect.Method.invokeNative(Native Method) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at java.lang.reflect.Method.invoke(Method.java:521) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at dalvik.system.NativeStart.main(Native Method) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): Caused by: android.database.sqlite.SQLiteException: no such column: journals._id: UPDATE plants SET days = (SELECT COUNT(*) FROM plants WHERE journals._id = plants.homeid) 08-21 00:07:46.624: ERROR/AndroidRuntime(12943): at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)