Skip to main content

How to compare two columns ignoring Case (Upper or Lower case)

  • August 22, 2013
  • 6 replies
  • 23 views

Shibashis_Beher
Vertica comparision is seems case specific Shiba is not equal to SHIBA. I want to ignore cases when compairing. Is there a shortcut to set session paramater for this instead doing UPPER(A) = UPPER(B)

6 replies

Forum|alt.badge.img+2
  • Participating Frequently
  • August 22, 2013
Hi Shibashis, Vertica supports Unicode (ie., non-English) strings; as a result, there are actually multiple ways to do a case-insensitive comparison. Take a look at database locales; specifically the 'collation' option: https://my.vertica.com/docs/6.1.x/HTML/index.htm#13786.htm https://my.vertica.com/docs/6.1.x/HTML/index.htm#14070.htm I suspect one (or more) of these will suit your needs. Adam

Daniel_Leybovic
Forum|alt.badge.img+1
  • Participating Frequently
  • August 23, 2013
Hi! You can use in ILIKE: daniel=> select 'Shiba' ilike 'SHIBA'; ?column? ---------- t (1 row) daniel=> select 'Vertica' ~~* 'VerTicA'; ?column? ---------- t (1 row)

Shibashis_Beher
  • Author
  • New Participant
  • August 24, 2013
I have many cases in where condition and i do not want to use UPPER or ilike clause in each and every comparison. i want to know if we can alter any session parameter that will by default compare all fields ignoring cases in that session?

Forum|alt.badge.img+2
  • Participating Frequently
  • August 25, 2013
Hi Shibashis, I pointed you at the relevant parameters in my previous post; are they working well for you? Thanks, Adam

Sharon_Cutter
Forum|alt.badge.img
  • Participating Frequently
  • August 26, 2013
Consider fixing your data so that all data is consistently in the same case. Having to uppercase strings in order to do comparisons will only waste cpu and possibly decrease the effectiveness of encoding and compression. Vertica's sweet spot is fast queries - don't degrade the performance with your data model.

Nicholas_Chamma_1
Forum|alt.badge.img
Hey Adam, Would setting colStrength = secondary cover Shibashis's original use case? Nick