Android Sqlite IN, NOT IN syntax --- not int (?)

处理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 ..." 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

转载于:https://www.cnblogs.com/veins/p/4050341.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值