I have a database containing user details. I don’t have separate columns for ‘firstname’ and ‘lastname’. I have used only a single column: ‘name’. My query is like this:
ps_details=con.prepareStatement("select * from student_details where name=?");
ps_details.setString(1,name);
The problem is:
In db the name is stored in UPPERCASE. So when the user types his/her name in lowercase or mixed-case, the search is unsuccessful. What is the efficient solution for this problem?
Further, what if ‘name’ are stored in db in lower-case, mixed-case as well as uppercase, i.e., if the case is not known before hand. I also want to use like clause
I am using Oracle 11g Express Editon.
UPPER – the upper function converts all letters in the specified string to uppercase. Use it on both the variable (user input) and table column values, convert them both to the same case for comparison to handle both problems. (You could also use lower – the idea is to convert both to the same case for comparison). *EDITED FOR LIKE with only the postceding wildcard *
This you have to play with, but I think you can also do the following with the wildcard.