Ignore Letter Case in Search?
i was wondering how id be able to ignore the letter case of names when i searched for contacts. heres my search method:publicvoid searchContacts(String contactName, JPanel searchPanel){
try{
statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from CONTACTS where NAME like '%" + contactName +"%'");
while(resultSet.next()){
searchName = resultSet.getString("NAME");
searchNumber = resultSet.getString("NUMBER");
searchEMail = resultSet.getString("EMAIL");
searchPanel.add(new ContactPanel(searchName, searchNumber, searchEMail));
}
}catch (SQLException ex){
ex.printStackTrace();
}
}
thnx for any help
[1323 byte] By [
Alex1989a] at [2007-11-27 11:48:59]

Normally SQL queries ARE case insensitive aren't they?
So if your CONTACTS table contains 'xyZ' and 'XYz', and you search for 'xyz', it should return both rows.
i thought sql syntax was case insensitive but values are sensitive?
try (something like) this:
resultSet = statement.executeQuery("select * from CONTACTS where LOWER(NAME) like '%" + contactName.toLowerCase() + "%'");
> i thought sql syntax was case insensitive but values
> are sensitive?
Not in Microsoft and MySQL... the values are case insensitive as well.
Just doing a like should be sufficient (provided the OP is using MS or MySQL). I don't know about Oracle or PostgreSQL.
just ran a test in oracle - it's the LIKE clause thats seems to be case sensitive!
select name from case where name LIKE '%secondo%'
returns name il secondo
select name from case where name LIKE '%Secondo%'
returns nothing
> i thought sql syntax was case insensitive but values
> are sensitive?
>
> try (something like) this:
> > resultSet = statement.executeQuery("select * from
> CONTACTS where LOWER(NAME) like '%" +
> contactName.toLowerCase() + "%'");
>
thnx bud that solved it