-1
我想用查詢中的值初始化遊標。該查詢是爲了返回表1中不在表2中的內容。爲此,我使用了MINUS
子句,但它似乎沒有工作,而且我也看不到我出錯的地方。Android SQLite MINUS查詢
查詢
return db.rawQuery("select _id, ingredient_name, measurement, unit from ingredients where recipe_code = " + recipe_code +
" MINUS select ingredient_name, measurement, unit from kitchen", null);
錯誤
02-05 11:35:05.189 29028-29028/com.example.rory.prototypev2 E/AndroidRuntime: android.database.sqlite.SQLiteException: near "MINUS": syntax error (code 1): , while compiling: select _id, ingredient_name, measurement, unit from ingredients where recipe_code = 11 MINUS select ingredient_name, measurement, unit from kitchen
什麼是MINUS? –
@M D SQL MINUS運算符用於返回第一個SELECT語句中不由第二個SELECT語句返回的所有行。每個SELECT語句將定義一個數據集。 MINUS操作員將從第一個數據集中檢索所有記錄,然後從結果中刪除第二個數據集中的所有記錄。 –
但''SQLite'不支持這種'MINUS'類型的關鍵字 –