{"id":501,"date":"2011-05-04T12:58:43","date_gmt":"2011-05-04T12:58:43","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=501"},"modified":"2023-10-12T21:52:02","modified_gmt":"2023-10-13T04:52:02","slug":"mysql-substring","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-substring\/","title":{"rendered":"MySQL SUBSTRING() Function"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to the MySQL <code>SUBSTRING()<\/code><strong> <\/strong>function that extracts a substring from a string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL SUBSTRING() function<\/h2>\n\n\n\n<p>The <code>SUBSTRING()<\/code> function allows you to extract a substring from a string. MySQL provides various forms of the substring function.<\/p>\n\n\n\n<p>We will examine each form of the <code>SUBSTRING<\/code> function in the following sections.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1) SUBSTRING() function with position parameter<\/h3>\n\n\n\n<p>The following illustrates the first form the <code>SUBSTRING()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">SUBSTRING(string, position);\nSUBSTRING(string FROM position);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax, the <code>SUBSTRING()<\/code> function has two parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>string<\/code>. The string from which you want to extract the substring.<\/li>\n\n\n\n<li><code>position<\/code>. This is an <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-int\/\">integer<\/a> that specifies the starting character of the substring. The <code>position<\/code> can be a positive or negative integer.<\/li>\n<\/ul>\n\n\n\n<p>If the <code>position<\/code> is positive, the <code>SUBSTRING()<\/code> function extracts the substring from the start of the string. For example:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"377\" height=\"48\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png\" alt=\"MySQL substring - string demo\" class=\"wp-image-2233\" title=\"MySQL substring - string demo\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png 377w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo-300x38.png 300w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><\/figure>\n\n\n\n<p>For example, to extract the &#8221; <code>SUBSTRING<\/code>&#8221; from the &#8221; <code>MySQL SUBSTRING<\/code>&#8221; string, the starting position of the substring must be 7 as the following <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-select-from\/\"><code>SELECT<\/code><\/a> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">SUBSTRING<\/span>(<span class=\"hljs-string\">'MYSQL SUBSTRING'<\/span>, <span class=\"hljs-number\">7<\/span>); <span class=\"hljs-comment\">-- SUBSTRING<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-substring\/#1\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n\n<p>If the position is negative, the <code>SUBSTRING()<\/code> function extracts the substring from the end of the string. See the following &#8221; <code>MYSQL SUBSTRING<\/code>&#8221; string:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"415\" height=\"46\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQLsubstring-with-negative-position.png\" alt=\"MySQLsubstring function with negative position\" class=\"wp-image-2235\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQLsubstring-with-negative-position.png 415w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQLsubstring-with-negative-position-300x33.png 300w\" sizes=\"auto, (max-width: 415px) 100vw, 415px\" \/><\/figure>\n\n\n\n<p>To get the &#8221; <code>SUBSTRING<\/code>&#8221; out of the &#8221; <code>MySQL SUBSTRING<\/code>&#8221; using a negative position, you pass <code>-10<\/code> to the <code>position<\/code> argument as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">SUBSTRING<\/span>(<span class=\"hljs-string\">'MySQL SUBSTRING'<\/span>,<span class=\"hljs-number\">-10<\/span>); <span class=\"hljs-comment\">--  SUBSTRING<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-substring\/#2\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n\n<p>Notice that if the position is zero, the <code>SUBSTRING()<\/code> function returns an empty string:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">SUBSTRING<\/span>(<span class=\"hljs-string\">'MYSQL SUBSTRING'<\/span>, <span class=\"hljs-number\">0<\/span>); <span class=\"hljs-comment\">-- ''<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-substring\/#3\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n\n<p>Besides the MySQL-specific syntax, you can use SQL-standard syntax with the <code>FROM<\/code> keyword to call the <code>SUBSTRING<\/code> function.<\/p>\n\n\n\n<p>For example, the following statement gets the <code>SUBSTRING<\/code> from the <code>MySQL SUBSTRING<\/code> string using the SQL-standard syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">SUBSTRING<\/span>(<span class=\"hljs-string\">'MySQL SUBSTRING'<\/span> <span class=\"hljs-keyword\">FROM<\/span> <span class=\"hljs-number\">-10<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-substring\/#4\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2) SUBSTRING function with position and length arguments<\/h3>\n\n\n\n<p>If you want to specify the length of the substring that you want to extract from a string, you can use the following form of the <code>SUBSTRING<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">SUBSTRING(string, position, length);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following is the SQL-standard version of the above statement, which is longer but more expressive.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">SUBSTRING(string FROM position FOR length);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Besides the <code>string<\/code> and <code>position<\/code> arguments, the <code>SUBSTRING()<\/code> function has an additional <code>length<\/code> argument. <\/p>\n\n\n\n<p>The <code>length<\/code> can be a positive integer that specifies the number of characters of the substring.<\/p>\n\n\n\n<p>If the sum of <code>position<\/code> and <code>length<\/code> is greater than the number of characters of the string, the <code>SUBSTRING()<\/code> function returns a substring starting from the position to the end of the string.<\/p>\n\n\n\n<p>For example, to get the &#8221; <code>MySQL<\/code>&#8221; from the &#8220;<code>MySQL SUBSTRING<\/code>&#8220;, you use the following statement:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"377\" height=\"48\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png\" alt=\"MySQL substring - string demo\" class=\"wp-image-2233\" title=\"MySQL substring - string demo\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png 377w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo-300x38.png 300w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">SUBSTRING<\/span>(<span class=\"hljs-string\">'MySQL SUBSTRING'<\/span>,<span class=\"hljs-number\">1<\/span>,<span class=\"hljs-number\">5<\/span>); <span class=\"hljs-comment\">-- MySQL<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-substring\/#5\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n\n<p>Or<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">SUBSTRING<\/span>(<span class=\"hljs-string\">'MySQL SUBSTRING'<\/span> <span class=\"hljs-keyword\">FROM<\/span> <span class=\"hljs-number\">1<\/span> <span class=\"hljs-keyword\">FOR<\/span> <span class=\"hljs-number\">5<\/span>); <span class=\"hljs-comment\">-- MySQL<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-substring\/#6\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n\n<p>If you want to use the negative position, you use the following statement:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"415\" height=\"46\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQLsubstring-with-negative-position.png\" alt=\"MySQLsubstring function with negative position\" class=\"wp-image-2235\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQLsubstring-with-negative-position.png 415w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQLsubstring-with-negative-position-300x33.png 300w\" sizes=\"auto, (max-width: 415px) 100vw, 415px\" \/><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">SUBSTRING<\/span>(<span class=\"hljs-string\">'MySQL SUBSTRING'<\/span>,<span class=\"hljs-number\">-15<\/span>,<span class=\"hljs-number\">5<\/span>); <span class=\"hljs-comment\">-- MySQL<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-substring\/#7\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n\n<p>Or with the <code>FROM FOR<\/code> syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">SUBSTRING<\/span>(<span class=\"hljs-string\">'MySQL SUBSTRING'<\/span> <span class=\"hljs-keyword\">FROM<\/span> <span class=\"hljs-number\">-15<\/span> <span class=\"hljs-keyword\">FOR<\/span> <span class=\"hljs-number\">5<\/span>); <span class=\"hljs-comment\">-- MySQL<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-substring\/#8\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n\n<p>The <code>SUBSTR()<\/code> is the synonym for the <code>SUBSTRING()<\/code> so you can use both of them interchangeably.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the MySQL <code>SUBSTRING()<\/code> function to extract a substring from a string.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"501\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-substring\/\"\n\t\t\t\tdata-post-title=\"MySQL SUBSTRING() Function\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"501\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-substring\/\"\n\t\t\t\tdata-post-title=\"MySQL SUBSTRING() Function\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to use the MySQL SUBSTRING() function to extract a substring from a string.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":7027,"menu_order":12,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-501","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL SUBSTRING() Function<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to use the MySQL SUBSTRING() function to extract a substring from a string.\" \/>\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-substring.aspx\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL SUBSTRING() Function\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to use the MySQL SUBSTRING() function to extract a substring from a string.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-13T04:52:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png\" \/>\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-substring.aspx\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-substring.aspx\",\"name\":\"MySQL SUBSTRING() Function\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-substring.aspx#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-substring.aspx#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/mysql-substring-string-demo.png\",\"datePublished\":\"2011-05-04T12:58:43+00:00\",\"dateModified\":\"2023-10-13T04:52:02+00:00\",\"description\":\"In this tutorial, you will learn how to use the MySQL SUBSTRING() function to extract a substring from a string.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-substring.aspx#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-substring.aspx\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-substring.aspx#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/mysql-substring-string-demo.png\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/mysql-substring-string-demo.png\",\"width\":377,\"height\":48},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-substring.aspx#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL String Functions\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-string-functions\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL SUBSTRING() Function\"}]},{\"@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 SUBSTRING() Function","description":"In this tutorial, you will learn how to use the MySQL SUBSTRING() function to extract a substring from a string.","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-substring.aspx","og_locale":"en_US","og_type":"article","og_title":"MySQL SUBSTRING() Function","og_description":"In this tutorial, you will learn how to use the MySQL SUBSTRING() function to extract a substring from a string.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx","og_site_name":"MySQL Tutorial","article_modified_time":"2023-10-13T04:52:02+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx","url":"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx","name":"MySQL SUBSTRING() Function","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png","datePublished":"2011-05-04T12:58:43+00:00","dateModified":"2023-10-13T04:52:02+00:00","description":"In this tutorial, you will learn how to use the MySQL SUBSTRING() function to extract a substring from a string.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-substring.aspx"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-substring-string-demo.png","width":377,"height":48},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-substring.aspx#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL String Functions","item":"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/"},{"@type":"ListItem","position":3,"name":"MySQL SUBSTRING() Function"}]},{"@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\/501","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=501"}],"version-history":[{"count":3,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/501\/revisions"}],"predecessor-version":[{"id":11077,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/501\/revisions\/11077"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/7027"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}