{"id":8587,"date":"2020-05-19T14:44:18","date_gmt":"2020-05-19T04:44:18","guid":{"rendered":"https:\/\/database.guide\/?p=8587"},"modified":"2020-05-28T13:42:20","modified_gmt":"2020-05-28T03:42:20","slug":"how-sqlite-lower-works","status":"publish","type":"post","link":"https:\/\/database.guide\/how-sqlite-lower-works\/","title":{"rendered":"How SQLite Lower() Works"},"content":{"rendered":"\n<p>The <a href=\"https:\/\/database.guide\/what-is-sqlite\/\">SQLite<\/a> <code>lower()<\/code> function allows you to convert a string to lowercase characters. <\/p>\n\n\n\n<p>More precisely, it returns a copy of its argument, with all ASCII characters converted to lowercase. <\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<p>Here&#8217;s a basic example to demonstrate.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT lower('BLACK Cat');<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">black cat<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Database Example<\/h2>\n\n\n\n<p>Here&#8217;s an example of using the <code>lower()<\/code> function in a query against a database column.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT \n  CatName,\n  lower(CatName)\nFROM Cats;<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CatName &nbsp; &nbsp; lower(CatName)\n----------&nbsp; --------------\nBrush &nbsp; &nbsp; &nbsp; brush&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\nBrash &nbsp; &nbsp; &nbsp; brash&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\nBroosh&nbsp; &nbsp; &nbsp; broosh &nbsp; &nbsp; &nbsp; &nbsp;\n100%Fluff &nbsp; 100%fluff&nbsp; &nbsp; &nbsp;\n100$Fluff &nbsp; 100$fluff&nbsp; &nbsp; &nbsp;<\/pre>\n\n\n\n<p>Here, the left column contains the original value, and the right column contains those values converted to lowercase.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Number of Arguments<\/h2>\n\n\n\n<p>The <code>lower()<\/code> function requires one, and only one, argument. <\/p>\n\n\n\n<p>If you provide no arguments, you&#8217;ll get an error.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT lower();<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error: wrong number of arguments to function lower()<\/pre>\n\n\n\n<p>And if you provide too many arguments, you&#8217;ll also get an error.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT lower('Black', 'Cat');<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error: wrong number of arguments to function lower()<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Non-ASCII Characters<\/h2>\n\n\n\n<p>As mentioned, <code>lower()<\/code> only works on ASCII characters (the 26 letters used in the English language). SQLite only understands upper\/lower case for ASCII characters by default.<\/p>\n\n\n\n<p>You can load the <a aria-label=\"SQLite ICU extension (opens in a new tab)\" href=\"https:\/\/www.sqlite.org\/src\/artifact?ci=trunk&amp;filename=ext\/icu\/README.txt\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"aioseop-link\">SQLite ICU extension<\/a> if you need to do case conversions on non-ASCII characters. <\/p>\n\n\n\n<p>The ICU based functions provided by this extension provide case mapping, where defined, for the full range of unicode characters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The SQLite lower() function allows you to convert a string to lowercase characters. More precisely, it returns a copy of its argument, with all ASCII characters converted to lowercase.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[93,67],"class_list":["post-8587","post","type-post","status-publish","format-standard","hentry","category-sqlite","tag-functions","tag-string-functions"],"_links":{"self":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/8587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/comments?post=8587"}],"version-history":[{"count":6,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/8587\/revisions"}],"predecessor-version":[{"id":8819,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/8587\/revisions\/8819"}],"wp:attachment":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/media?parent=8587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/categories?post=8587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/tags?post=8587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}