【问题标题】:how to use like operation in sqlite android如何在sqlite android中使用like操作
【发布时间】:2016-09-09 10:38:19
【问题描述】:

我正在一个 android 应用程序中使用 sqlite 处理数据库我想使用 like 子句获取一些数据

cursor = db.rawQuery("select * from INTERESTS contactid LIKE '%=?%'", new String[]{id + ""});

【问题讨论】:

  • 仅供参考:使用非常容易处理的Realm。

标签: android sqlite android-sqlite


【解决方案1】:

假设您真的想使用 LIKE 运算符:? 变量不要放在引号中。您可以使用|| 连接变量和文字:

contactid LIKE `%` || ? || '%'

(在 LIKE 模式中省略了 =,因为它看起来不合适。)

假设您实际上想要一个完全匹配而不是 LIKE:

contactid = ?

【讨论】:

    猜你喜欢
    • 2012-06-08
    • 1970-01-01
    • 2016-02-15
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-07
    • 2017-12-10
    相关资源
    最近更新 更多