【问题标题】:getContentResolver().query android where clausegetContentResolver().query android where 子句
【发布时间】:2013-01-24 10:22:39
【问题描述】:

我的查询是关于从数据库中获取数据的函数参数的创建。

我希望光标只返回特定的行而不是完整的记录集。

c= getContentResolver().query(uri, null, "column1=? \"mysearch\" or column2=? "\mysearch"\", null, "date DESC");

我想获得column1 像“mysearch”或column2 像“mysearch”的结果。

在上面的示例中,我尝试了一些硬编码值。

问候,

尼拉夫

【问题讨论】:

    标签: android sqlite cursor


    【解决方案1】:

    经过一些解决方法后得到它。

    正确的查询将是

    String searchQuery = "column1 like '%" + searchKey
                    + "%' or column2 like '%" + searchKey + "%'";
    
    
            c = getContentResolver().query(uri, null, searchQuery, null,
                    "date DESC");
    

    谢谢,

    尼拉夫

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-28
      • 2014-10-03
      • 1970-01-01
      • 1970-01-01
      • 2020-07-26
      • 2021-07-23
      • 2011-03-29
      • 2016-04-10
      相关资源
      最近更新 更多