I\'m trying to run NOT IN
select where NOT IN
list is dynamic. Something like
SELECT id, type FROM CONTACTS where type NOT IN (\'connec
You can have it dynamically use "not in" if you dynamically create a String that contains the list of "not in" values and then append them to the end of your sql string like in the following:
public static Vector selectAllFormTypesForAccountIgnoringFormVersions(
int accountId, String formsIgnored) {
protected final static String selectAllFormTypesForAccountIgnoringFormVersions = "SELECT DISTINCT FormType.*"
+ " FROM FormType, Form WHERE Form.accountId=? AND FormType.formTypeContentId = Form.formTypeContentId"
+ " AND Form.formVersionId NOT IN (";
Vector allFormTypes = new Vector();
SQLiteDatabase db = null;
String[] selectionArgs = { Integer.toString(accountId)};
try {
DataManager_Platform dataManager = (DataManager_Platform) DataManager_Platform
.getDataManager();
db = (SQLiteDatabase) dataManager.getDatabase();
Cursor cursor = db.rawQuery(
selectAllFormTypesForAccountIgnoringFormVersions + formsIgnored + ")",
selectionArgs);
if (cursor.getCount() > 0) {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
FormType_Platform formType = new FormType_Platform();
formType.populateModel(cursor);
allFormTypes.add(formType);
cursor.moveToNext();
}
}
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
} finally {
try {
if (db != null) {
db.close();
}
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
}
}
return allFormTypes;
}