[英]Android SQLite query string to reach to D in A~B~C~D~E~F where A,B,C,D,E and F could have any interested length and data
In an Android application,在 Android 应用程序中,
In SQLite
database, there is a column with the following data:在
SQLite
数据库中,有一列包含以下数据:
A~B~C~D~E~F A~B~C~D~E~F
Where each of A,B,C,D,E and F could have variable length and data其中 A、B、C、D、E 和 F 中的每一个都可以具有可变长度和数据
For example,例如,
A could be every possible interested name like Mike, Andy, Tom , ... A 可以是所有可能感兴趣的名字,例如 Mike、Andy、Tom ......
Or B could be any interested country name and so on或者 B 可以是任何感兴趣的国家名称等等
Now I need a Query to reach to D part, how?现在我需要一个查询来到达 D 部分,如何?
FYI, '~' character
is unique in the data (there would be just 5 characters of '~')仅供参考,
'~' character
在数据中是唯一的('~' 只有 5 个字符)
In other word, A,B,C,D,E,F don't contain '~'
换句话说,A、B、C、D、E、F 不包含
'~'
Edit: I need LIKE clause in a basic SQLite编辑:我需要基本 SQLite 中的 LIKE 子句
I actually don't know of a way to do this using only the basic SQLite string functions.我实际上不知道只使用基本的 SQLite 字符串函数来做到这一点的方法。 Therefore, I would suggest handling this from Java, after you have queried:
因此,在您查询之后,我建议从 Java 处理此问题:
String input = "A~B~C~D~E~F";
String[] parts = input.split("~");
String target = parts.length >= 4 ? parts[3] : "";
Eureka!尤里卡! It's possible with LIKE clause (NOT LIKE) in a basic SQLite:
在基本 SQLite 中使用 LIKE 子句(NOT LIKE)是可能的:
SELECT_QUERY =
String.format("SELECT * FROM %s WHERE %s NOT LIKE %s;",
Constants.TABLE_M4,
Constants.KEY_M4_Data,
"%~%~%~~%'"
);
If D
is not empty, it is identified with the above query如果
D
不为空,则用上面的查询标识
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.