SQLite:选择连续行中不带小数的字母数字条目
我有一个 SQLite DB,其中包含一系列字母数字代码和描述。这两个字段都是文本。编码格式是单个字母字符后跟 2 位数字值 - 这是父类别。许多父类别都有子项目 - 其中代码由小数点扩展,然后是字母数字值...因此:
A01 是父类别
A01.10 是子项目
我想SELECT
没有子项的代码...此表中有 80000 个条目,因此手动遍历它并不理想;)
因此,包含标准是代码 [an][n][n] 存在且[an][n][n].% 不存在...任何想法/指导表示赞赏:)
TABLE
称为“Terms”,Code 字段想象地称为 Code TIA
I have an SQLite DB comprising of a series of alphanumerical codes and descriptions. Both fields are TEXT. The coding format is a single alphabetical character followed by 2 digit numerical value - this is the parent category. Many parent categories have sub-items - where the code is extended by a decimal and then an alphanumerical value... so:
A01 is a parent category
A01.10 is a subitem
I would like to SELECT
the codes where there are no sub-items... There are 80000 entries in this table, so going through it manually isn't ideal ;)
So, the inclusion criteria are where code [an][n][n] exists AND [an][n][n].% doesn't exist... Any ideas / guideance appreciated :)
The TABLE
is called 'Terms' and the Code field is imaginatively called Code
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
字符串处理并不完全是 SQLite 的强项,但我认为你可以用一种稍微迂回的方式来完成它:
这个想法是首先找出哪些代码有子项,然后排除它们。
给定这些数据:
然后该查询会给出以下结果:
String processing isn't exactly SQLite's strong point but I think you get it done in a slightly round about way:
The idea is to first figure out which codes have sub-items and then exclude them.
Given this data:
Then that query gives you this: