How to Use SQL Query for Case Sensitive Data in Magento 2
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 |
1 | GL1 |
2 | Gl1 |
1 |
syntax = SELECT * FROM `table` WHERE BINARY `column` = 'value' |
1 |
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.
Any doubts about the above method can be mentioned in the Comments section below. I’d be glad to help you out.
Also, do share the post with the Magento Community via social media.
Thank you.
Sanjay 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.
Prev
Magento Community vs Enterprise Edition Comparison [2024]
How to Create Zip File in Magento 2
Next