android - Sqlite query to get list of next available characters after the matching search keyword
问题描述
How to query sqlite database to get list of next available characters after the search keyword in a string field. for example, if the search keyword is ’and’</p>
and let the strings be a list of names like :
- Andy Xyz
- Andrew Xyz
- Xyz Andon
- Xyz Miranda
then i should get the characters [y,r,o,a].
I tried the query with substr(names,1,1), but substr needs to specify the start index which will be different in each strings. Is it possible to fetch these characters using sqlite query?
解决方案
你需要substr()
和instr()
:
select
substr(names, instr(lower(names), lower('and')) + length('and'), 1) nextchar
from tablename
where
names like '%' || 'and' || '_%'
查看演示您可以在上述查询中
替换为您希望的任何字符串。'and'
推荐阅读
- angular - Angular 6:从组件单击会导致 href 值添加到 URL
- php - 在 Woocommerce Checkout 的计费国家下方添加自定义字段
- perl - Perl 是否有可能通过响应 0 移动成功?
- google-cloud-platform - 如何在 Google VM 上设置 SSH 防火墙规则,以便只有我的办公室计算机可以通过 SSH 访问 VM?
- python - Python Virtualenv 目录更改
- parsing - Scrapy(开源 Web 抓取框架)如何工作?
- machine-learning - 构建模型时如何使用日期变量?
- angular7 - 如何通过新的 @angular/cli v7 angular.json 或 custom-webpack.config.js 添加额外的 postcss 插件?
- javascript - 如何更改样式元素html?
- aws-lambda - 从同一 VPC 中的 Lambda 连接到 Elasticsearch 服务