This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Ignoring case in queries......... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Ignoring case in queries........." Watch "Ignoring case in queries........." New topic
Author

Ignoring case in queries.........

Mallika Kumar
Ranch Hand

Joined: Feb 15, 2001
Posts: 61
Hi,
Is there a way I can make SQL queries case-insensitive in the select statement itself ? I'm passing user entered values to a prepared statement. My select statement looks like :
SELECT EMPNO,EMPNAME FROM EMPLOYEE WHERE EMPNAME LIKE ?
I'm using preparedStatement.setString(1,inputValue). Instead of modifing the inputValue with String class(ie,changing its case to format it to Mallika or Kumar,ie first letter capitalized and the rest in small case), can I specify in select statement itself to ignore the case of inputValue being passed ?
Any suggestions would be helpful.
Thanks.
Daniel Dunleavy
Ranch Hand

Joined: Mar 13, 2001
Posts: 276
you can use the UPPER or LOWER functions to put everything in the same case.
The best thing to do is put it the way you need it in the database and use the upper/lower on the incoming data. If you use it on the database side I think the indexes will not be used.
ex: where name = upper(clientside_name)
Dan
 
 
subject: Ignoring case in queries.........
 
Similar Threads
Hibernate: changing case of table name
SQL Question
how to use sessions in shopping cart like application
defference jdbcTemplate.queryForInt() and others
How do lower/upper work in SQL?