Case insensitive SELECT

How would you create a select statement the ignores case. For instance if I had

SELECT * FROM contacts WHERE last_name = “smith”

Is there a way to have the query match “Smith” as well?

SELECT * FROM contacts WHERE lower(last_name) = “smith”;

Is this locale friendly or is it english (or ascii) only?

Locale friendly, using Unicode rules.

https://golang.org/pkg/strings/#ToLower

I don’t know if you’re familiar with the Turkish language problem.

I (capital i) -> ı (lower case i without dot on top)
İ (capital i with dot on top) -> i

This is how the conversion takes place in Turkish. When I try this in Query window, it doesn’t convert as expected:

Not familiar. Try the interactive window here. We use the same underlying mechanism. Try strings.ToLower().

https://golang.org

I did in the page. It doesn’t do what I expect either. Looks like I’ll have to find another solution.

I’m sorry about that.

FYI, @geraldss, this is a problem I ran into way back in 2001 at a previous company. In Turkish there is one letter that is ASCII in upper case, and non-ASCII in lower case, and a different letter for which the reverse is true. It sounds like golang’s case-handling routines don’t do the correct thing in this case. (Java fixed it way back in 2001).

2 Likes