Android Sqlite IN, NOT IN syntax --- not int (?)
2014-10-25 16:53
274 查看
处理where column_name not in (?):如果后面是一串字符或数字组合时,不可以直接用(?)来处理,而应该将这些字符组合直接作为条件字符串的一部分。
1. where column_name not in ('name1','name2')
2. db.query(TABLE, new String[] { "id", ""}, String.format(" type NOT IN (%s)", argsArrayToString(arrays)), null, null, null, null);
You cannot place just one '?' instead of a list of values. As such, there is little to gain from trying to parametrize lists. One can, of course, create 2,4,16-value prepared statements
if the list is dynamic, you will have to escape the strings and put them into single quoted list.
Via: http://stackoverflow.com/questions/4707367/android-sqlite-in-not-in-syntax
1. where column_name not in ('name1','name2')
2. db.query(TABLE, new String[] { "id", ""}, String.format(" type NOT IN (%s)", argsArrayToString(arrays)), null, null, null, null);
You cannot place just one '?' instead of a list of values. As such, there is little to gain from trying to parametrize lists. One can, of course, create 2,4,16-value prepared statements
..." type NOT IN (?,?)", new String[]{ "connect","answer" },...but even on a server with remote RDBMS it has questionable value. Istead, do
db.query(TABLE, new String[] { "id", ""}, " type NOT IN ('connect','answer')", null, null, null, null);
if the list is dynamic, you will have to escape the strings and put them into single quoted list.
Via: http://stackoverflow.com/questions/4707367/android-sqlite-in-not-in-syntax
相关文章推荐
- Android.Could not find *.apk in android 2.1
- How to store an image file to SQliteDB in android
- location of the android sdk has not been setup in the preferences的解决方法
- sqlite database lock problem in android content providers
- Android.Could not find *.apk in android 1.5
- Using SQLite from Shell in Android
- android点滴2:The method...in the type View is not...
- Android 设置环境出现Java not found in your path的解决办法
- Using SQLite in Android Application
- SQLite in Android part 1
- Google to Android Developers: 'Do Not Develop in the Open'
- Sorry, the command is not available in this version: syntax enable的解决方法
- location of the android sdk has not been setup in the preferences
- HttpPost works in Java project, not in Android
- Using your own SQLite database in Android applications
- android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or da
- Image is not displaying proper using OpenGL in android ndk
- Android中java.lang.ClassNotFoundException: ***.**** in loader dalvik.system.PathClassLoader[/data/app
- Using your own SQLite database in Android applications
- 关于android分支无法下载的问题,revision froyo in manifests not found