Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Ignore Case in DB2 SQL

Posted on 2012-03-28
2
Medium Priority
?
2,047 Views
Last Modified: 2012-03-30
Hi Everyone,

I'm trying to design a query/CASE statement that will ignore the case of a field. Example: 'APPLE' and "Apple'.
I would like to combine the following two separate statements into one statement.
WHEN FOOD = 'APPLE'                  THEN ' Fruit'
WHEN FOOD = 'Apple'                   THEN ' Fruit'

Thanks in advance!

Mark
0
Comment
Question by:Mark1M
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Dave Ford earned 2000 total points
ID: 37779702
The classic answer to this dilemma involves applying the UPPER function:

WHEN Upper(FOOD) = 'APPLE'  THEN ' Fruit'

Alternately, some "flavors" of DB2 support defining your data with "case-insensitive sort-sequence", but that's significantly more complex. Let me know if you want more details on that one.

HTH,
DaveSlash
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 37780487
note that using such a function can significantley hurt the performance of the query because it might cause db2 to not use an index on the food column
if you only have two options (all upper case letters or the first letter is upper case and the rest are lower case) you might be better off using the in predicate
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question