How to delete rows in SQLite with multiple where args?

前端 未结 6 914
陌清茗
陌清茗 2021-02-01 04:59

I want to delete rows which satisfy any of multiple conditions.

For example, I pass a list of IDs, and I want to delete all rows with these IDs (IDs are uni

6条回答
  •  长情又很酷
    2021-02-01 05:53

    You could use id IN (1, 2, 3, 4, ...) and directly print your array values inside the brackets:

    database.delete("rows", String.format("id IN (%s)", StringUtils.join(ids, ",")));
    

    As an alternative, I'd try to use some kind of flags column for such things (if there's something like being able to flag single entries for deletion; I don't know how your ID list is "built").

提交回复
热议问题