{"id":112,"date":"2009-03-13T08:29:03","date_gmt":"2009-03-13T12:29:03","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2009\/03\/13\/performing-mysql-query-with-case-sensitivity\/"},"modified":"2009-03-13T08:29:03","modified_gmt":"2009-03-13T12:29:03","slug":"performing-mysql-query-with-case-sensitivity","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2009\/03\/13\/performing-mysql-query-with-case-sensitivity\/","title":{"rendered":"Performing MySQL query with case sensitivity"},"content":{"rendered":"<p>Let us take note of the following example data.<\/p>\n<table border=\"1\" style=\"background-color: #ffffff; color: #000000;\">\n<tr style=\"background-color: #c0c0c0;\">\n<th>WEBSITE_NAME<\/th>\n<\/tr>\n<tr>\n<td>dev-notes.com<\/td>\n<\/tr>\n<tr>\n<td>Dev-Notes.com<\/td>\n<\/tr>\n<tr>\n<td>DEV-NOTES.com<\/td>\n<\/tr>\n<\/table>\n<p>Note that the first row is in all lower case, the second in proper case, and the third contains all capitalized letters.  If we run a normal MySQL select statement to search for &#8220;dev-notes&#8221; such as the below, the system will return all three records.<\/p>\n<pre class=\"code\">\n\/* Standard query; not case sensitive *\/\nselect * from mytable where website_name='dev-notes.com';\n<\/pre>\n<p>To get around it, simply use the &#8220;binary&#8221; keyword before the column name, shown in the example below.<\/p>\n<pre class=\"code\">\n\/* Case sensitive query *\/\nselect * from mytable where binary website_name='dev-notes.com';\n<\/pre>\n<p>The query above will only return the first record, which is the one that contains all lower case letters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, MySQL queries are not case sensitive.  By using the &#8220;binary&#8221; keyword, we can easily match by specific casing when necessary.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}