{"id":7027,"date":"2018-08-26T08:20:26","date_gmt":"2018-08-26T15:20:26","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=7027"},"modified":"2024-01-28T04:45:56","modified_gmt":"2024-01-28T11:45:56","slug":"mysql-string-functions","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/","title":{"rendered":"MySQL String Functions"},"content":{"rendered":"\n<p>This page shows you the most commonly used MySQL string functions that allow you to manipulate character string data effectively.<br>\n<input id=\"search\" class=\"light-table-filter\" type=\"text\" placeholder=\"Type a function name to search...\" data-table=\"functions\"><\/p>\n\n\n\n<figure class=\"wp-block-table functions is-style-regular\"><table><thead><tr><th>Name<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-concat\/\">CONCAT<\/a><\/td><td>Concatenate two or more strings into a single string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-concat_ws\/\">CONCAT_WS<\/a><\/td><td>Return a single string by concatenating multiple strings separated by a specified separator.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-instr\/\">INSTR<\/a><\/td><td>Return the position of the first occurrence of a substring in a string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-string-length\/\">LENGTH<\/a><\/td><td>Get the length of a string in bytes.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-char_length\/\">CHAR_LENGTH<\/a><\/td><td>Return the length of a string measured in characters.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-left-function\/\">LEFT<\/a><\/td><td>Get a specified number of leftmost characters from a string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-lower\/\">LOWER<\/a><\/td><td>Return a string converted to lowercase.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-locate-function\/\">LOCATE<\/a><\/td><td>Return the position of a substring within a given string starting at a specified position.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-ltrim-function\/\">LTRIM<\/a><\/td><td>Remove all leading spaces from a string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-replace-function\/\">REPLACE<\/a><\/td><td>Replace all occurrences of a substring in a string with a new one.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-repeat-function\/\">REPEAT<\/a><\/td><td>Repeat a string a specified number of time.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-reverse-function\/\">REVERSE<\/a><\/td><td>Reverse a string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-right-function\/\">RIGHT<\/a><\/td><td>Get a specified number of rightmost characters from a string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-rtrim-function\/\">RTRIM<\/a><\/td><td>Remove all trailing spaces from a string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-substring\/\">SUBSTRING<\/a><\/td><td>Extract a substring starting from a position with a specific length.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-substring_index-function\/\">SUBSTRING_INDEX<\/a><\/td><td>Return a substring from a string before a specified number of occurrences of a delimiter.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-trim-function\/\">TRIM<\/a><\/td><td>Remove unwanted characters from a string.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-find_in_set\/\">FIND_IN_SET<\/a><\/td><td>Find a string within a comma-separated list of strings.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-format-function\/\">FORMAT<\/a><\/td><td>Format a number with a specific locale, rounded to the number of decimals.<\/td><\/tr><tr><td><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-upper\/\">UPPER<\/a><\/td><td>Convert a string to uppercase.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Concatenation Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-concat\/\">CONCAT()<\/a>: Combines two or more strings into a single string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-concat_ws\/\">CONCAT_WS()<\/a>: Combines multiple strings into a single string with a specified separator.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Substring Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-substring\/\">SUBSTRING()<\/a>: Extracts a substring from a given string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-substring_index-function\/\">SUBSTRING_INDEX()<\/a>: Extracts a substring from a string using a delimiter.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-left-function\/\">LEFT()<\/a>: Returns a specified number of characters from the beginning of a string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-right-function\/\">RIGHT()<\/a>: Returns a specified number of characters from the end of a string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-substring\/\">MID()<\/a>: Extracts a substring from the middle of a string. The MID() function is a synonym for SUBSTRING().<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Searching and Locating Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-locate-function\/\">LOCATE()<\/a>: Finds the position of a substring within a string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-locate-function\/\">POSITION()<\/a>: Finds the position of a substring. The <code>POSITION()<\/code> is a synonym for the <code>LOCATE()<\/code> function.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-instr\/\">INSTR()<\/a>: Another function for finding the position of a substring.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Case Conversion Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-upper\/\">UPPER()<\/a>: Converts a string to uppercase.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-lower\/\">LOWER()<\/a>: Converts a string to lowercase.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Character Manipulation Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-replace-function\/\">REPLACE()<\/a>: Replaces all occurrences of a substring in a string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-trim-function\/\">TRIM()<\/a>: Removes leading and trailing spaces from a string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-ltrim-function\/\">LTRIM()<\/a>: Removes leading spaces from a string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-rtrim-function\/\">RTRIM()<\/a>: Removes trailing spaces from a string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-repeat-function\/\">REPEAT()<\/a>: Repeats a string a specified number of times.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-reverse-function\/\">REVERSE()<\/a>: Reverses the characters in a string.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-insert-function\/\">INSERT()<\/a>: Replaces a substring within a string with a new substring.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Whitespace Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SPACE(): Returns a string consisting of spaces.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-ascii\/\">ASCII()<\/a>: Returns the ASCII value of the leftmost character of a string.<\/li>\n\n\n\n<li>CHAR(): Converts an ASCII value to a character.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Length and Count Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-string-length\/\">LENGTH()<\/a>: Returns the length of a string in bytes.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-char_length\/\">CHAR_LENGTH()<\/a>: Returns the length of a string in characters.<\/li>\n\n\n\n<li>OCTET_LENGTH(): Returns the length of a string in bytes.<\/li>\n\n\n\n<li>BIT_LENGTH(): Returns the length of a string in bits.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-char_length\/\">CHARACTER_LENGTH()<\/a>: Returns the length of a string in characters.<\/li>\n\n\n\n<li>BIT_COUNT(): Counts the number of bits in a binary string.<\/li>\n\n\n\n<li>STRCMP(): Compares two strings and returns their relative order.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Padding string functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-lpad\/\">LPAD()<\/a> &#8211; Left-pads a string with a set of characters to a specified length.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-rpad\/\">RPAD()<\/a> &#8211; Right-pads a string with a set of characters to a specified length.<\/li>\n<\/ul>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This page lists MySQL string functions that allow you to manipulate strings effectively.<\/p>\n","protected":false},"author":2,"featured_media":10070,"parent":0,"menu_order":18,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-7027","page","type-page","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL String Functions<\/title>\n<meta name=\"description\" content=\"This page lists the most commonly used MySQL string functions that allow you to manipulate strings effectively.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL String Functions\" \/>\n<meta property=\"og:description\" content=\"This page lists the most commonly used MySQL string functions that allow you to manipulate strings effectively.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-28T11:45:56+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/\",\"name\":\"MySQL String Functions\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-string-functions.svg\",\"datePublished\":\"2018-08-26T15:20:26+00:00\",\"dateModified\":\"2024-01-28T11:45:56+00:00\",\"description\":\"This page lists the most commonly used MySQL string functions that allow you to manipulate strings effectively.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-string-functions.svg\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-string-functions.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL String Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL String Functions","description":"This page lists the most commonly used MySQL string functions that allow you to manipulate strings effectively.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/","og_locale":"en_US","og_type":"article","og_title":"MySQL String Functions","og_description":"This page lists the most commonly used MySQL string functions that allow you to manipulate strings effectively.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-28T11:45:56+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/","url":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/","name":"MySQL String Functions","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-string-functions.svg","datePublished":"2018-08-26T15:20:26+00:00","dateModified":"2024-01-28T11:45:56+00:00","description":"This page lists the most commonly used MySQL string functions that allow you to manipulate strings effectively.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-string-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-string-functions.svg","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-string-functions.svg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL String Functions"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/7027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=7027"}],"version-history":[{"count":4,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/7027\/revisions"}],"predecessor-version":[{"id":14588,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/7027\/revisions\/14588"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media\/10070"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=7027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}