如题 , 比如只有一个name列的表t1,数据如下:
name
张三2
李四
王五*
要查出‘张三2’,‘王五*’两条记录,他们都包含非中文字符。
更新
-----------------------------------------------------------------
尝试过使用正则表达式:
select customername from transactionrecord where regexp_like(customername , '[^\u4e00-\u9fa5]')
但是在oralce中测试无效。可能是由于字符集不同导致的不能工作?
感谢你的回答!
这篇文章已经参考过,但是没有找到解决方案,这篇文章是说,判断是否包含【中文字符】,而不是是否包含【非中文】字符。
@yanwushu: Oracle的SQL中的正则表达式不支持\u,要用unistr,参考Searching Unicode characters in Oracle table
@yanwushu: 也就是:
select customername from transactionrecord where regexp_like(customername , '[^' || unistr('\4e00') || '-' || unistr('\9fa5') || ']')
@dudu: 感谢你的回答!
问题已经解决,sql如下:
select customername from transactionrecord
where regexp_like(customername , '[^' ||unistr('\4e00')|| '-' ||unistr('\9fa5')||']');