[英]How can I specify a case insensitive search in Java
I currently have this code in place:我目前有这个代码:
query = "select ID_OBJECT from "+Config.props.getProperty("Ob.SchemaName.Objects")+".sdm_doc_info where name like ? and typefileverscurr = 'DWG'";
However this only returns results that match the upper case DWG.但是,这仅返回与大写 DWG 匹配的结果。 I would like my search to be case insensitive.
我希望我的搜索不区分大小写。 How can I use ?i in this case?
在这种情况下,我该如何使用?i? I tried the following but my Eclipse does not like it:
我尝试了以下操作,但我的 Eclipse 不喜欢它:
query = "select ID_OBJECT from "+Config.props.getProperty("Ob.SchemaName.Objects")+".sdm_doc_info where name like ? and typefileverscurr.matches('(?i:dwg)')";
Thanks for your help.谢谢你的帮助。
Usually I use to do these kind of jobs in two ways, One is by using the SQL upper()
or lower()
functions, like this:通常我用两种方式做这些工作,一种是使用 SQL
upper()
或lower()
函数,像这样:
"select ID_OBJECT from "+something+".sdme_doc_info where lower(typefileverscurr) = 'dwg'";
OR或者
"select ID_OBJECT from "+something+".sdme_doc_info where upper(typefileverscurr) = 'DWG'";
And another way is to use like
in the query and mix above functions as well to make more insensitive另一种方法是在查询中使用
like
并混合上述功能以及使更不敏感
"select ID_OBJECT from "+something+".sdme_doc_info where lower(typefileverscurr) like '%dwg%'";
OR或者
"select ID_OBJECT from "+something+".sdme_doc_info where upper(typefileverscurr) like '%DWG%'";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.