如何在 sqlite 中使用 like 操作 android
how to use like operation in sqlite android
我正在 android 应用程序中使用 sqlite 处理数据库 我想使用 like 子句获取一些数据
cursor = db.rawQuery("select * from INTERESTS contactid LIKE '%=?%'", new String[]{id + ""});
假设您真的想使用 LIKE 运算符:?
变量不要用引号引起来。您可以使用 ||
连接变量和文字:
contactid LIKE `%` || ? || '%'
(在 LIKE 模式中省略了 =
,因为它看起来不合适。)
假设您实际上想要完全匹配而不是 LIKE:
contactid = ?
我正在 android 应用程序中使用 sqlite 处理数据库 我想使用 like 子句获取一些数据
cursor = db.rawQuery("select * from INTERESTS contactid LIKE '%=?%'", new String[]{id + ""});
假设您真的想使用 LIKE 运算符:?
变量不要用引号引起来。您可以使用 ||
连接变量和文字:
contactid LIKE `%` || ? || '%'
(在 LIKE 模式中省略了 =
,因为它看起来不合适。)
假设您实际上想要完全匹配而不是 LIKE:
contactid = ?