sqlite - sqlite 从具有多个“名称”的单列中选择 DISTINCT?
问题描述
我有一张有中文拼音的桌子。我想获得所有独特的音节发音。
我跑了
SELECT DISTINCT col FROM tab
但它给了我太多。
我的专栏有像
a1
a2
a3
a4
但它也有多个单词值,其中可能包含一个唯一值,例如:
a1 巴1
a2 fa1
我如何使用 distinct 自己也获得像“ba1”和“fa1”这样的值?
解决方案
您可以使用 UNION 也拒绝重复:
select col from tab where col not like '% %'
union
select substr(col, 1, instr(col, ' ') - 1) from tab where col like '% %'
union
select substr(col, instr(col, ' ') + 1) from tab where col like '% %'
查看演示
推荐阅读
- javascript - 如何在webgl上渲染具有指定宽度和高度的二维精灵
- javascript - 如何使用 node.js 从 mySQL 读取数据并回传到 HTML?
- android - react native 应用不是最新打包的页面
- c# - Asp.net Core Entity Framework Linq where 查询测试两个布尔值是否相等
- python - ValueError:轴与数组不匹配
- php - 如何使用 edd_store_discount 功能排除下载,以便轻松进行数字下载插件
- amadeus - 企业用户如何将经过测试的自助服务 REST API 移动到生产环境?
- ios - 可以使用 IndexPath(item: 0, section: 0) 为 TableView 设置 IndexPath
- android - Simpletarget 是否已弃用 glide?
- react-native-navigation - 在 react-native-navigation 中,如何在不导航的情况下更新选定的标签栏图标?