{"id":1936,"date":"2021-11-10T17:51:52","date_gmt":"2021-11-10T17:51:52","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/use-sql-query-for-case-sensitive-data-in-magento-2\/"},"modified":"2025-07-16T17:03:18","modified_gmt":"2025-07-16T11:33:18","slug":"use-sql-query-for-case-sensitive-data-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/use-sql-query-for-case-sensitive-data-in-magento-2\/","title":{"rendered":"How to Use SQL Query for Case Sensitive Data in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Ever had to deal with postcodes in\u00a0Magento 2\u00a0store for managing the shipping charges?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Is your business charging&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-shipping-table-rates.html\" target=\"_blank\" rel=\"noreferrer noopener\">shipping rates in Magento 2<\/a>&nbsp;store based on the location of delivery?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, if there is a variation in postcodes, for example, uppercase and lowercase, there are chances of errors in the calculation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The solution to avoid it is to use&nbsp;<em><strong>SQL query for case sensitive data in Magento 2<\/strong><\/em>. Use the below method to differentiate the postcode with uppercase or lowercase and accordingly charge the shipping rates!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can use this method where you want to differentiate values based on the case sensitivity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Use SQL Query for Case Sensitive Data in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Dataset:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Table Name: Custom<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><strong>No.<\/strong><\/th><th><strong>PostCode<\/strong><\/th><\/tr><\/thead><tbody><tr><td>1<\/td><td>GL1<\/td><\/tr><tr><td>2<\/td><td>Gl1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>syntax = SELECT *  FROM `table` WHERE BINARY `column` = 'value'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>example = SELECT *  FROM Custom WHERE BINARY Postcode = GL1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When you run the above query, you\u2019ll get the below output:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No Postcode<br>1 GL1<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do share the post with the Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever had to deal with postcodes in\u00a0Magento 2\u00a0store for managing the shipping charges? Is your business charging&nbsp;shipping rates in Magento 2&nbsp;store based on the location&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1936","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1936"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1936\/revisions"}],"predecessor-version":[{"id":18010,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1936\/revisions\/18010"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}