🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Use SQL Query for Case Sensitive Data in Magento 2

By Sanjay JethvaUpdated on Jul 16, 2025 1 min read

Ever had to deal with postcodes in Magento 2 store for managing the shipping charges?

Is your business charging shipping rates in Magento 2 store based on the location of delivery?

If yes, you might have to juggle between the postcodes assigned to the shipping rules and the values entered by the frontend user in your store. Magento assigns the shipping charges by matching the postcode and the shipping rule configured.

However, if there is a variation in postcodes, for example, uppercase and lowercase, there are chances of errors in the calculation.

The solution to avoid it is to use SQL query for case sensitive data in Magento 2. Use the below method to differentiate the postcode with uppercase or lowercase and accordingly charge the shipping rates!

You can use this method where you want to differentiate values based on the case sensitivity.

Method to Use SQL Query for Case Sensitive Data in Magento 2:

Dataset:

Table Name: Custom

No.PostCode
1GL1
2Gl1
syntax = SELECT *  FROM `table` WHERE BINARY `column` = 'value'
example = SELECT *  FROM Custom WHERE BINARY Postcode = GL1

When you run the above query, you’ll get the below output:

No Postcode
1 GL1

That’s it.

Also, do share the post with the Magento Community via social media.

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.