How to make your Postgres DB query case insensitive?

Have you been working with a database that may not have all the entries in a table with consistent case? If you want to make sure that you can still lookup this database without worrying about case sensitivity, then this is the blog post for you.

Let us say that there is a table called clients, from which you would like to pull a few attributes based on the hostname. An example of a case insensitive query would be that you convert the hostname in the table as well as the search query to upcase or downcase to make it uniform.


SELECT attribute_1, attribute_2, attribute_3 FROM data_table WHERE UPPER(hostname) = '#{hostname.upcase}'

Previous
Previous

How to troubleshoot 802.1x association issues on Windows?

Next
Next

How to clone a linux user?