Sqlite DELETE与JOIN错误

时间:2016-05-31 19:35:04

标签: android sqlite

我正在尝试从db2中删除存在于db2中的记录。这是我的疑问:

db.execSQL("attach database '" + db_path + "' as db2");
db.execSQL("DELETE CategoryProduct_MM FROM CategoryProduct_MM INNER JOIN db2.CategoryProduct_MM t2 ON CategoryProduct_MM.PrdID = t2.PrdID AND CategoryProduct_MM.CategoryID=t2.CategoryID");

我收到了这个错误:

--------- beginning of crash
    05-31 20:59:54.242 30323-30323/me.superup.updatedb E/AndroidRuntime: FATAL EXCEPTION: main
     Process: me.superup.updatedb, PID: 30323
     android.database.sqlite.SQLiteException: near "CategoryProduct_MM": syntax error (code 1): , while compiling: DELETE CategoryProduct_MM FROM CategoryProduct_MM INNER JOIN superup.CategoryProduct_MM t2 ON CategoryProduct_MM.PrdID = t2.PrdID AND CategoryProduct_MM.CategoryID=t2.CategoryID
         at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
         at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
         at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
         at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
         at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
         at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
         at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1674)
         at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605)

我做错了什么?

0 个答案:

没有答案