Today I Learned

hashrocket A Hashrocket project

How to search case sensitively in Postgres

There's nothing special about this, I'm just a dummy who only ever used ilike and never thought twice about it.

Today, I learned that ilike is just a case-insensitive version of like.

This would return any rows with a name of Peter

select * from users
where name ilike '%peter%'
;
SQL

This would not return any rows with a name of Peter

select * from users
where name like '%peter%'
;
SQL

Stay tuned for tomorrow's TIL where I tell you about how I learned the sky is blue! 😂

See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.