如何SQL比较列当一个人重音字符? [英] How to SQL compare columns when one has accented chars?

查看:402
本文介绍了如何SQL比较列当一个人重音字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个SQLite的表,我很想加入他们的名字列。此列包含重音字符,所以我想知道我怎么可以比较它们的加入。我想放弃的工作比较口音。

I have two SQLite tables, that I would love to join them on a name column. This column contains accented characters, so I am wondering how can I compare them for join. I would like the accents dropped for the comparison to work.

推荐答案

您可以影响人物的比较(如忽略大小写,忽略重音)使用排序规则。 SQLLite只有少数建于归类,但你可以添加你自己的。

You can influence the comparison of characters (such as ignoring case, ignoring accents) by using a Collation. SQLLite has only a few built in collations, although you can add your own.

  • SqlLite, Data types, Collating Sequences
  • SqlLite, Define new Collating Sequence

编辑: 鉴于这似乎令人怀疑,如果Android支持UDF和计算列,这里的另一种方法:

Given that it seems doubtful if Android supports UDFs and computed columns, here's another approach:

  • 添加另一列到表,normalizedName
  • 当你的应用程序写出行的表,它规范化名字本身,去掉口音和表演等变化。它将结果保存在normalizedName。
  • 您在您的加入使用normalizedName。

由于归一化的功能,现在在Java中,你应该有它的编码数的限制。除去在Java口音几个例子给出这里

As the normalization function is now in java, you should have few restrictions in coding it. Several examples for removing accents in java are given here.

这篇关于如何SQL比较列当一个人重音字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆