2013-12-18 92 views
2
String Where = "SELECT FROM peopleTable WHERE _id BETWEEN " + i1+ " AND " + i2; 

哪裏錯了嗎? logcat的:的Android SQlite的遊標查詢錯誤

12-18 16:47:54.497: E/SQLiteLog(2447): (1) near "SELECT": syntax error 
12-18 16:47:54.757: E/AndroidRuntime(2447): FATAL EXCEPTION: main 
12-18 16:47:54.757: E/AndroidRuntime(2447): android.database.sqlite.SQLiteException: near "SELECT": syntax error (code 1): , while compiling: SELECT _id, persons_name, persons_hotness FROM peopleTable WHERE SELECT FROM peopleTable WHERE _id BETWEEN 2 AND 4 
+0

。 – VishalKale

+0

所以如何寫出請簡單告訴我。 @VishalKale – mhtamun

+0

看答案下面我已經寫了有... – VishalKale

回答

1

您正在使用內另一個SELECT這就是爲什麼它給一個語法錯誤,不是因爲BETWEEN子句SELECT代替

SELECT _id, 
persons_name, 
persons_hotness FROM 
peopleTable WHERE SELECT 
FROM peopleTable WHERE 
_id BETWEEN 2 AND 4 

使用此查詢

SELECT _id, 
persons_name, 
persons_hotness FROM 
peopleTable WHERE 
_id BETWEEN 2 AND 4 



db.query("peopleTable", 
new String[] {_id, person_name,    person_hotness}, 
"WHERE _id BETWEEN 2 AND 4",  null, null, null, null); 
+0

那麼它是如何可以寫成請你告訴我在編程代碼。 @VishalKale – mhtamun

+0

現在檢查編輯答案... – VishalKale

+0

非常感謝你 – mhtamun