ILIKE sushi

I don’t actually like sushi. As a matter of fact, it ranks right up there with mushroom quiche on the “food hate” scale. But I find it wicked funny that the case-insensitive SQL command for filtering by a string is ILIKE (the case sensitive version is LIKE). It means you can end up writing a query that looks like this code snippet:

   SELECT galleries.name, COUNT(images.id)
   FROM galleries JOIN images
   ON galleries.id = images.gallery_id
   WHERE images.name ILIKE ‘sushi’
   GROUP BY galleries.id ORDER BY galleries.id;

I’m easily amused.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Skip to content