我有一個查詢,使一個內部連接2臺與此關口: 字表:婦女參與發展,wname,wsyn,wlevel wordchoice表:婦女參與發展,CH1,CH2,CH3 但是當我想用在波紋管這個查詢,在日誌貓我收到錯誤!如何更正此查詢?
words table : wid, wname, wsyn, wlevel
wordchoice table :wid, ch1, ch2, ch3
public Cursor getText2() {
SQLiteDatabase db = getReadableDatabase();
String mySQL1= "select w.wid,w.wname,w.wsyn,c.ch1,c.ch2,c.ch3"
+ " from words w INNER JOIN wordchoice c"
+" ON w.wid=c.wid"
+ " where wid=?"
+ " and wlevel=?"
;
String[] args= {"7", "1"};
Cursor c2 = db.rawQuery(mySQL1,args);
c2.moveToFirst();
return c2;
}
最新問題?
的logcat:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{ir.project.g5/ir.project.g5.test}: android.database.sqlite.SQLiteException: ambiguous column name: wid: , while compiling: select w.wid,w.wname,w.wsyn,c.ch1,c.ch2,c.ch3 from words w INNER JOIN wordchoice c ON w.wid=c.wid where wid=? and wlevel=?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$600(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: ambiguous column name: wid: , while compiling: select w.wid,w.wname,w.wsyn,c.ch1,c.ch2,c.ch3 from words w INNER JOIN wordchoice c ON w.wid=c.wid where wid=? and wlevel=?
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java)
at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java)
at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java)
at ir.project.g5.DBHelper.getText2(DBHelper.java:79)
at ir.project.g5.test.onCreate(test.java:141)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
... 12 more
那是什麼,你收到的錯誤? –
「_in logcat i recive error_」和「_whats the problem?_」。要回答你的問題,我們需要真正看到logcat的輸出...使用的問題下面的[**編輯**](http://stackoverflow.com/posts/16813485/edit)按鈕來添加它,和唐「不要忘記它在未來的問題.. – jlordo
也許你需要在WHERE子句w.wid和w.wlevel(添加表的別名)來指定。 – selalerer