【问题标题】:Using like with where clause for deleting in android在android中使用like with where子句进行删除
【发布时间】:2013-10-05 06:11:25
【问题描述】:

我正在开发一个 android 应用程序,我想根据 where 子句和 like 子句删除一行。以下是我尝试过的代码,

            String where = "numberp Like '%''"+phonetounbold+"'";
            String[] whereArgs = null;

            delcount = db.delete("NUMBERLIST", where, whereArgs);

在上表中,我想从 NUMBERLIST 表中删除一行,其中包含来自 numberp 列的类似 phonetounbold 的字符串。但是上面的查询不起作用。我的语法哪里出错了。请帮忙。谢谢!

【问题讨论】:

    标签: android mysql sqlite where-clause sql-like


    【解决方案1】:

    尝试将“where”子句改为

    String where = "numberp LIKE '%"+phonetounbold+"'";

    【讨论】:

      【解决方案2】:

      如果您使用原始 SQLiteDatabase 接口而不是内容提供者进行开发,则可以直接使用execSQL 方法:

      database.execSQL("delete from numberlist where numberp like '%xyz%'")
      

      【讨论】:

        【解决方案3】:

        试试这个

        String where = "numberp Like '%" + phonetounbold + "'";
        

        【讨论】:

          猜你喜欢
          • 2014-01-17
          • 1970-01-01
          • 1970-01-01
          • 2013-06-27
          • 1970-01-01
          • 1970-01-01
          • 2014-08-07
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多