简体   繁体   English

Android SQLite 查询字符串到达​​ A~B~C~D~E~F 中的 D,其中 A、B、C、D、E 和 F 可以有任何感兴趣的长度和数据

[英]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.

相关问题 安卓 如何将String =(AB,CD,EF,…)切换为String(BA,DC,FE,…) - Android. How to switch String = (A B, C D, E F, …) to String (B A, D C, F E, …) Android,我可以将NumberPicker更改为CharPicker {A +,A,B +,B.C +,C,D +,D,F} - Android , Could I change NumberPicker to CharPicker {A+,A,B+,B.C+,C,D+,D,F} 仅显示自定义字母 - a、b、c、d、e(Android 键盘) - Show custom alphabets - a,b,c,d,e only (Android Keyboard) 如何完成A,B,C,D,E的特定活动? - How to finish specific activity from A,B,C, D, E? 错误:(1,0)插件太旧而且ANDROID_DAILY_OVERRIDE值也过时,请使用新值:“11f0c8f6a19f6b805f4d0f4ecbec99d777fb7c60” - Error:(1, 0) Plugin is too old and ANDROID_DAILY_OVERRIDE value is also outdated, please use new value :“11f0c8f6a19f6b805f4d0f4ecbec99d777fb7c60” sh -f和-d被视为-e - sh -f and -d are being treated as -e 如何恢复碎片? 我在调用这些片段的不同按钮上创建了四个片段-A,B,C,D - How to resume the fragments ? I have created four fragments -A,B,C,D on diffrent buttons im calling these fragments e.g 找不到ID为0x7f0e00d5(com.example.page:id/dialogViewpager)的片段OneFragment {92c0220#1 id = 0x7f0e00d5 android:switcher:2131624149:0} - No view found for id 0x7f0e00d5 (com.example.page:id/dialogViewpager) for fragment OneFragment{92c0220 #1 id=0x7f0e00d5 android:switcher:2131624149:0} java.lang.IllegalStateException:已添加片段:BottomSheetFragment{fc9d1db} (f54104c4-f862-420b-b30a-3fbd835554cf)} - java.lang.IllegalStateException: Fragment already added: BottomSheetFragment{fc9d1db} (f54104c4-f862-420b-b30a-3fbd835554cf)} Android ViewBinding 错误:无法访问 class 'android.widget.no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40' - Android ViewBinding Error: Cannot access class 'android.widget.no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM