Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case insensitive search in Java DB (Derby)

Tags:

jdbc

derby

javadb

I'm using Derby and I can't find a way to do case insensitive search.

For example, I have a table that I'm searching that contains "Hello" but I put a search query in for "hello" and at the moment I won't get a result, but I want to.

I can't find the correct syntax for it.

Sara

like image 531
Sara Avatar asked May 21 '11 19:05

Sara


People also ask

How do you make a case insensitive search?

We need to set the NLS_COMP parameter to LINGUISTIC, which will tell the database to use NLS_SORT for string comparisons. Then we will set NLS_SORT to a case insensitive setting, like BINARY_CI. By default, NLS_COMP is set to BINARY.

What is case insensitive search?

By default, searches are case-insensitive. You can make your search case-sensitive by using the case filter. For example, the following search returns only results that match the term HelloWorld . It excludes results where the case doesn't match, such as helloWorld or helloworld . case:yes HelloWorld.

Is JDBC query case sensitive?

ODBC/JDBC connection to the database is case sensitive in regards to database name.


1 Answers

You can use the UPPER() or LOWER() SQL functions on both your search argument and the field, like in

SELECT *
FROM   mytab
WHERE  UPPER(lastname) = UPPER('McDonalds')
like image 64
MikeD Avatar answered Sep 23 '22 22:09

MikeD