2014-02-06 45 views
0

這裏是選擇Query.Every時候我收到錯誤:未能在Android中使用SQLITE執行簡單的「選擇」查詢?

SELECT 
     mf.id, 
     mf.field_type_id, 
     mf.field_label, 
     mf.field_values as mf_values, 
     mf.is_required, 
     sfv.field_value as sfv_Value 
FROM menu_fields mf 
LEFT OUTER JOIN site_field_values sfv 
ON mf.id=sfv.menu_fields_id 
AND sfv.proposal_id=100000 WHERE mf.menu_id=2; 

這裏是logcat的

02-06 22:36:05.010: E/SQLiteLog(27524): (1) near "mf": syntax error 
02-06 22:36:05.015: D/AndroidRuntime(27524): Shutting down VM 02-06 
22:36:05.015: W/dalvikvm(27524): threadid=1: thread exiting with 
uncaught exception (group=0x41bdf2a0) 02-06 22:36:05.030: 
E/AndroidRuntime(27524): FATAL EXCEPTION: main 02-06 22:36:05.030: 
E/AndroidRuntime(27524): android.database.sqlite.SQLiteException: near 
"mf": syntax error (code 1): , while compiling: SELECT 
mf.id,mf.field_type_id,mf.field_label,mf.field_values as mf_values 
mf.is_required, sfv.field_value as sfv_Value FROM menu_fields mf LEFT 
OUTER JOIN site_field_values sfv ON mf.id=sfv.menu_fields_id AND 
sfv.proposal_id=100000 WHERE mf.menu_id=2 02-06 22:36:05.030: 
E/AndroidRuntime(27524): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native 
Method) 02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1012) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:623) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37) 02-06 
22:36:05.030: E/AndroidRuntime(27524): at 
android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
com.mrfs.android.surveyapp.db.SiteCRUD.getAllSite(SiteCRUD.java:71) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
com.mrfs.android.surveyapp.activities.fragments.SiteFragmentActivity.onCreateView(SiteFragmentActivity.java:51) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
android.os.Handler.handleCallback(Handler.java:615) 02-06 
22:36:05.030: E/AndroidRuntime(27524): at 
android.os.Handler.dispatchMessage(Handler.java:92) 02-06 
22:36:05.030: E/AndroidRuntime(27524): at 
android.os.Looper.loop(Looper.java:137) 02-06 22:36:05.030: 
E/AndroidRuntime(27524): at 
android.app.ActivityThread.main(ActivityThread.java:4898) 02-06 
22:36:05.030: E/AndroidRuntime(27524): at 
java.lang.reflect.Method.invokeNative(Native Method) 02-06 
22:36:05.030: E/AndroidRuntime(27524): at 
java.lang.reflect.Method.invoke(Method.java:511) 02-06 22:36:05.030: 
E/AndroidRuntime(27524): at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 
02-06 22:36:05.030: E/AndroidRuntime(27524): at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 02-06 
22:36:05.030: E/AndroidRuntime(27524): at 
dalvik.system.NativeStart.main(Native Method) 

回答

0

你錯過了這兩列之間的逗號SELECT子句

mf_values mf.is_required