If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Case Insensitive Queries:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-11-10, 13:31
snowcl16 snowcl16 is offline
Registered User
 
Join Date: Oct 2010
Posts: 5
Post Case Insensitive Queries:

Hi, I use DB2 for AS/400.

Right now we use iSeriesNavigator v5r4.

When I run this sample query I get no results:

SELECT *
FROM MyTable
WHERE LastName = 'smith'

But this will return many results:

SELECT *
FROM MyTable
WHERE LastName = 'Smith'

I've tried adding SortSequence/SortType to my connection string (I'm using ASP.Net) and its still case sensitive. Any recommendations?
Reply With Quote
  #2 (permalink)  
Old 10-11-10, 14:31
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
WHERE UCASE(LastName) = 'SMITH'
or
WHERE UPPER(LastName) = 'SMITH'
or
WHERE LCASE(LastName) = 'smith'
or
WHERE LOWER(LastName) = 'smith'
__________________
Dick Brenholtz, Ami in Deutschland
Reply With Quote
  #3 (permalink)  
Old 10-11-10, 14:44
snowcl16 snowcl16 is offline
Registered User
 
Join Date: Oct 2010
Posts: 5
Quote:
Originally Posted by dbzTHEdinosaur View Post
WHERE UCASE(LastName) = 'SMITH'
or
WHERE UPPER(LastName) = 'SMITH'
or
WHERE LCASE(LastName) = 'smith'
or
WHERE LOWER(LastName) = 'smith'
That could work, but this just seems quite messy to me! Is there a smoother way to tackle this?
Reply With Quote
  #4 (permalink)  
Old 10-11-10, 15:29
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
WHERE LastName in ('Smith', 'smith' ...
would be more 'performance oriented' as there would be no function against every row.
__________________
Dick Brenholtz, Ami in Deutschland
Reply With Quote
  #5 (permalink)  
Old 10-11-10, 16:17
DB2Plus DB2Plus is offline
Registered User
 
Join Date: Jul 2009
Posts: 150
Lightbulb From = to like

When I met the same problem 2 years ago and try to solve by

Code:
Where UCASE(LastName) = 'SMITH'
it was created the big performance issue.

After this I found the solution without any performance affect:

Code:
Where (LastName like 's%' or LastName like 'S%')
            and Ucase(LastName) like '_MITH'
Kara
Reply With Quote
Reply

Tags
as400, db2, query

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On