Android Sqlite IN, NOT IN syntax

前端 未结 3 480
臣服心动
臣服心动 2021-02-05 06:54

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         


        
3条回答
  •  心在旅途
    2021-02-05 07:26

    You can use String.format to dynamic set the args.

    for example:

    db.query(TABLE, new String[] { "id", ""}, " type NOT IN (?)", "connect,answer", null, null, null);
    

    =>

    String argsArrayToString(List args) {
        StringBuilder argsBuilder = new StringBuilder();
        argsBuilder.append("(");
        final int argsCount = args.size();
        for (int i=0; i

提交回复
热议问题