首页 新闻 会员 周边

oralce查询字段中包含非中文字符的记录?

0
悬赏园豆:5 [已解决问题] 解决于 2015-01-24 16:51

如题 , 比如只有一个name列的表t1,数据如下:

  name  

  张三2

  李四

  王五*

要查出‘张三2’,‘王五*’两条记录,他们都包含非中文字符。

问题补充:

更新

-----------------------------------------------------------------

尝试过使用正则表达式:

  select customername from transactionrecord where regexp_like(customername , '[^\u4e00-\u9fa5]')

  但是在oralce中测试无效。可能是由于字符集不同导致的不能工作?

yanwushu的主页 yanwushu | 菜鸟二级 | 园豆:204
提问于:2015-01-24 16:02
< >
分享
最佳答案
0
收获园豆:5
dudu | 高人七级 |园豆:31003 | 2015-01-24 16:13

感谢你的回答!

这篇文章已经参考过,但是没有找到解决方案,这篇文章是说,判断是否包含【中文字符】,而不是是否包含【非中文】字符。

yanwushu | 园豆:204 (菜鸟二级) | 2015-01-24 16:25

@yanwushu: Oracle的SQL中的正则表达式不支持\u,要用unistr,参考Searching Unicode characters in Oracle table

dudu | 园豆:31003 (高人七级) | 2015-01-24 16:39

@yanwushu: 也就是:

select customername 
from transactionrecord 
where regexp_like(customername , '[^' || unistr('\4e00') || '-' || unistr('\9fa5') || ']')
dudu | 园豆:31003 (高人七级) | 2015-01-24 16:44

@dudu: 感谢你的回答!

问题已经解决,sql如下:

select customername from transactionrecord
where regexp_like(customername , '[^' ||unistr('\4e00')|| '-' ||unistr('\9fa5')||']');

yanwushu | 园豆:204 (菜鸟二级) | 2015-01-24 16:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册