{"id":149,"date":"2012-02-08T10:22:23","date_gmt":"2012-02-08T10:22:23","guid":{"rendered":"http:\/\/www.gnial.com.br\/gnialhelp\/?p=149"},"modified":"2019-11-26T10:42:54","modified_gmt":"2019-11-26T13:42:54","slug":"149","status":"publish","type":"post","link":"http:\/\/www.gnial.com.br\/gnialhelp\/149\/","title":{"rendered":"MySQL String Function \\ Fun\u00e7\u00e3o com Valores"},"content":{"rendered":"<p>In this section you can learn about the uses of MySQL String functions. These functions can be used to manipulate the string data. Here we have compiled the almost all String functions that you can use to learn more about string functions supported by MySQL.<\/p>\n<p><!--more--><\/p>\n<ul>\n<li><strong>ASCII (str)<br \/>\n<\/strong>The ASCII(str) function returns the ASCII code value of the leftmost character of the String <em><strong>str<\/strong><\/em>. Returns 0 if <strong><em> str<\/em><\/strong> is the empty string. Returns NULL if <strong><em> str<\/em><\/strong> is NULL. Here are the some example of the ASCII(str) function:<\/p>\n<pre>mysql&gt; SELECT ASCII('0'); \r\n-&gt; 48\r\nmysql&gt; SELECT ASCII(0);\r\n-&gt; 48\r\nmysql&gt; SELECT ASCII('d');\r\n-&gt; 100<\/pre>\n<\/li>\n<\/ul>\n<ul>\n<li><strong>BIN (N)<br \/>\n<\/strong>The BIN string function return a string value representing of the binary value of N, where N is a longlong(BIGINT) number. This function is equivalent to CONV(N, 10 , 0). If the function return the null then N is null. Here are the some example of the BIN(N) function:<\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">\u00a0mysql&gt; SELECT BIN(5); -&gt; &#8216;101&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<ul>\n<li><strong>BIT_LENGTH (str)<br \/>\n<\/strong>The BIT_LENGTH(str) function return the String <em><strong> str<\/strong><\/em> length in bits . Here are the some example of the BIT_LENGTH(str) function:<\/p>\n<table border=\"0\" width=\"48%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT BIT_LENGTH(&#8216;a&#8217;); -&gt; 8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<ul>\n<li><strong>CHAR(N,&#8230; [USING charset_name] )<br \/>\n<\/strong>The CHAR(N,&#8230; [USING charset_name] ) function\u00a0 return a string consisting the character and given the integer value. This function skipped the NULL values. Here are the some example of the CHAR(N,&#8230; [USING charset_name] ) function:\u00a0 <strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"48%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT CHAR(77,121,83,81,&#8217;76&#8217;); -&gt; &#8216;MySQL&#8217; mysql&gt; SELECT CHAR(66,66.3,&#8217;66.3&#8242;); -&gt; &#8216;BBB&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<ul>\n<li><strong>CHAR_LENGTH(str)<br \/>\n<\/strong>The CHAR_LENGTH(str) function returns String <strong><em> str<\/em><\/strong> lengths that is measured in characters. But in this function a multi-byte character counts as single character such as a string contains 5 two-byte characters, then LENGTH() function returns 10, but the CHAR_LENGTH() returns 5.<\/li>\n<li><strong>CHARACTER_LENGTH(str)<\/strong><br \/>\nThis function is same as CHAR_LENGTH().<\/li>\n<li><strong>CONCAT(str1, str2..)<br \/>\n<\/strong>The CONCAT(str1, str2?.) function can have one or more arguments and its returns a string that is the result of concatenating the arguments. In this function all arguments are non-binary strings then the result is also non-binary string but if any argument is binary string then result is binary string. And a numeric argument is converted to its equivalent binary string form. But if any argument is NULL then it also returns NULL. <strong><br \/>\n<\/strong> <strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"48%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT CONCAT(&#8216;In&#8217;, &#8216;d&#8217;, &#8216;ia&#8217;); -&gt; &#8216;India&#8217; mysql&gt; SELECT CONCAT(&#8216;my&#8217;, NULL, &#8216;ql&#8217;); -&gt; NULL mysql&gt; SELECT CONCAT(10.3); -&gt; &#8216;10.3&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>CONCAT_WS(separator str1, str2,&#8230;.)<br \/>\n<\/strong>The CONCAT_WS() means CONCAT With Separator. The first argument is treated as a separator for the rest of the arguments and it is added between the strings for concatenating. If the separator is NULL then the result is NULL. <strong>Example:<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT CONCAT_WS(&#8216;,&#8217;, &#8216; Title&#8217;, &#8216;First name&#8217;, &#8216;Last Name&#8217;); -&gt; &#8216;Title, First name, Last Name&#8217; mysql&gt; SELECT CONCAT_WS(&#8216;,&#8217;, &#8216;First name&#8217;, NULL, &#8216;Last Name&#8217;); -&gt; &#8216;First name, Last Name&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>CONV (N, from_base, to_base)<br \/>\n<\/strong>The CONV (N, from_base, to_base) function is used to convert the number between different number bases. This function returns a String that is representation of number N. It convert the number N from base <em><strong> from_base<\/strong><\/em> to base <em><strong>to_base<\/strong><\/em>. But it returns NULL if any argument is NULL. In this function argument N is interpreted as an integer, but it can be specified as a string or as a integer also. The minimum and the maximum base is 2 and 36 respectively. But if <em><strong> to_base<\/strong><\/em> is negative then N is treated as a signed number else it is treated as a unsigned number.<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\" height=\"132\">mysql&gt; SELECT CONV(&#8216;a&#8217;,10,2); -&gt; &#8216;0&#8217; mysql&gt; SELECT CONV(&#8216;6E&#8217;,10,5); -&gt; &#8217;11&#8217; mysql&gt; SELECT CONV(-17,9,-25); -&gt; &#8216;-G&#8217; mysql&gt; SELECT CONV(10+&#8217;10&#8217;+&#8217;10&#8217;+0xa,10,5); -&gt; &#8216;130&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>ELT(N,str1,str2,str3,&#8230;)<br \/>\n<\/strong>The ELT(N, str1, str2, str3,..) function returns <strong><em> str1<\/em><\/strong> if N=1 and <em><strong> str2<\/strong><\/em> if N=2 and so on. But it returns NULL if N is greater than the total number of arguments or less than 1. Here are some example of the ELT(N, str1, str2, str3,..) function:<br \/>\n<strong>Example:<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT ELT(1, &#8216;9&#8217;, &#8217;10&#8217;, &#8217;11&#8217;, &#8217;12&#8217;); -&gt; &#8216;9&#8217; mysql&gt; SELECT ELT(4, &#8216;9&#8217;, &#8217;10&#8217;, &#8217;11&#8217;, &#8217;12&#8217;); -&gt; &#8217;12&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>EXPORT_SET(bits,on,off[,separator[,number_of_bits]])<\/strong><br \/>\nThe EXPORT_SET(bits, on, off[, separator[,number_of_bits]]) function returns a string for a every bit set in the value <em><strong>bits<\/strong><\/em>, then you get the <em><strong> on<\/strong><\/em> String but for every reset bit you can get the <em><strong> off<\/strong><\/em> string. In this function Bits in <em><strong> bits<\/strong><\/em> are examined from right to left but Strings are concatenate to the result from left to right. The number of bits are calculated by given <em><strong> number_of_bits<\/strong><\/em> that?s default value is 64.<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT EXPORT_SET(1,&#8217;Y&#8217;,&#8217;N&#8217;,&#8217;,&#8217;,2); -&gt; &#8216;Y,N&#8217; mysql&gt; SELECT EXPORT_SET(6,&#8217;1&#8242;,&#8217;0&#8242;,&#8217;,&#8217;,2); -&gt; &#8216;0,1&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<ul>\n<li><strong>FIELD(str,str1,str2,str3,&#8230;)<br \/>\n<\/strong> The FIELD(str,str1,str2,str3,&#8230;.) function is used to find the index position of <em><strong> str<\/strong><\/em> in the arguments <strong><em>str1,str2,str3<\/em><\/strong>. In other words it returns the index position of <em><strong> str<\/strong><\/em> in the arguments. It returns 0 if <em><strong> str<\/strong><\/em> is not available in the arguments. If <em><strong> str<\/strong><\/em> is NULL then return value is 0 because NULL fails equality comparison with any value. <strong><br \/>\nExample:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT FIELD (&#8216;AA&#8217;, &#8216;BB&#8217;, &#8216;AA&#8217;, &#8216;CC&#8217;); -&gt; 2 mysql&gt; SELECT FIELD (&#8216;AA&#8217;, &#8216;BB&#8217;, &#8216;CC&#8217;, &#8216;DD&#8217;); -&gt; 0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>FIND_IN_SET(str,strlist)<\/strong><br \/>\nThe FIND_IN_SET(str, strlist) function returns a value in the range of 1 to N. This function find the String <em><strong> str<\/strong><\/em> in the substring of String list <em><strong> strlist<\/strong><\/em> and return the index value. This String list have many substrings that is separated by ?,? characters. This function returns 0 when <em><strong> str<\/strong><\/em> is not available in stringlist or string list is the empty string.<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT FIND_IN_SET(&#8216;2&#8217;, &#8216;1,2,3,4&#8217;); -&gt; 2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>FORMAT(X,D)<br \/>\n<\/strong>The FORMAT(X,D) function formats the number <strong>X<\/strong> like #,###,###.## and rounded the decimal places to <strong> D<\/strong> then returns the string as a result. But if D is 0 then the result don?t have fractional part. Some examples of the FORMAT(X, D) function are given below :<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"52%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT FORMAT(1235.14687, 3); -&gt; 1,235.147 mysql&gt; SELECT FORMAT(145678.1,2); -&gt; 145,678.10 mysql&gt; SELECT FORMAT(24567.1,0); -&gt; 24567<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>HEX(N_or_S)<br \/>\n<\/strong>In HEX(N_or_S) function <em><strong> N_or_S<\/strong><\/em> is a number then this function returns a string that is representation of hexadecimal value of N, where is a longlon(BIGINT) number. But if <em><strong> N_or_S<\/strong><\/em> is a string, then it returns a string hexadecimal representation of <em><strong> N_or_S<\/strong><\/em> where each character in <em><strong> N_or_S<\/strong><\/em> is converted to two hexadecimal digits. Here are some example of the HEX(N_or_S) function are given below:<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"52%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT HEX(10); -&gt; &#8216;A&#8217; mysql&gt; SELECT HEX( &#8216;abd&#8217;); -&gt; 616264<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>INSERT(str,pos,len,newstr)<br \/>\n<\/strong>The INSERT(str, pos, len, newstr) function is used to replace some part or whole String of String <em><strong> str<\/strong><\/em> with String <em><strong> newstr<\/strong><\/em> from beginning at position <strong><em> pos<\/em><\/strong> and <em><strong> len<\/strong><\/em> character long. This function returns the String <em><strong> str<\/strong><\/em> if <em><strong> pos<\/strong><\/em> is not within the length of the string. It returns NULL if any argument is NULL. <strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"52%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT INSERT(&#8216;roseindia&#8217;,2,3,&#8217;net&#8217;); -&gt; rnetindia mysql&gt; SELECT INSERT(&#8216;roseindia&#8217;,-1,3,&#8217;net&#8217;); -&gt; roseindia mysql&gt; SELECT INSERT(&#8216;roseindia&#8217;,3,100,&#8217;net&#8217;); -&gt;ronet<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>INSTR(str,substr)<br \/>\n<\/strong>The INSTR(str, substr) function is used to return the position of first occurrence of <strong><em> substr<\/em><\/strong> SubString in <em><strong> str<\/strong><\/em> String. Here are some example of the INSTR(str,substr) function: <strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"52%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFcc\" width=\"100%\">mysql&gt; SELECT INSTR(&#8216;roseindia&#8217;,&#8217;e&#8217;); -&gt; &#8216;4&#8217; mysql&gt; SELECT INSTR(&#8216;xe&#8217;, &#8216;roseindia&#8217;); -&gt; &#8216;0&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<ul>\n<li><strong>LOWER(str)<\/strong><br \/>\nThe LOWER(str) function return the String <em><strong>str<\/strong><\/em>. And in this String all the characters are changed in the lowercase.<\/p>\n<table border=\"0\" width=\"51%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFcc\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT LOWER(&#8216;ROSEINDIA&#8217;); -&gt;&#8217;roseindia&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>LCASE(str)<br \/>\n<\/strong>The LCASE(str) function is same as LOWER() function<\/li>\n<li><strong>LEFT(str,len)<br \/>\n<\/strong>The LEFT(str, len) function returns the leftmost <strong><em> len<\/em><\/strong> characters from the String <strong><em>str<\/em><\/strong>. Here are the some example of the LEFT(str, len) function:<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"52%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT LEFT(&#8216;roseindia&#8217;, 4); -&gt; &#8216;rose&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<ul>\n<li><strong>LENGTH(str)<br \/>\n<\/strong>The LENGTH(str) function returns the length of the String <strong><em> str<\/em><\/strong> in bytes. Here are the some example of the LENGTH(str) function:<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0 \" width=\"52%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT LENGTH(&#8220;roseindia&#8221;); -&gt;&#8217;9&#8242;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>LOAD_FILE(file_name)<br \/>\n<\/strong>The LOAD_FILE(file_name) function is used to read the file and this function returns the content of file as a string. For using it the file must be located on the server host., you must specify the full path of the file. But for using this function you must have FILE privilege and the file size is less than max_allowed_packet bytes.<\/p>\n<table border=\"0\" width=\"52%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT LOAD_FILE(&#8216;C:\/MySQL\/MySQL Server 5.0\/data&#8217;);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>LOCATE(substr,str), LOCATE(substr,str,pos)<br \/>\n<\/strong>The LOCATE(substr,str) function is same as INSTR(str, substr). LOCATE(substr,str,pos) function is\u00a0also same but its just start the to find first occurrence of substr in String <strong><em>str<\/em><\/strong> from position <strong><em>pos<\/em><\/strong>. These functions returns 0 if substr is not in String <strong><em>str<\/em><\/strong>. Here are the some example of the LOCATE(substr,str), LOCATE(substr,str,pos) function:<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"51%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT LOCATE(&#8216;in&#8217;,&#8217;roseindia&#8217;); -&gt; 5 mysql&gt; SELECT LOCATE(&#8216;xin&#8217;,&#8217;roseindia&#8217;); -&gt; 0 mysql&gt; SELECT LOCATE(&#8216;d&#8217;,&#8217;roseindia&#8217;,4); -&gt; 7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>LPAD(str,len,padstr)<br \/>\n<\/strong>The LPAD(str, len, padstr) function returns the string str that is left padded with padstr string for length of len characters. But string str is longer than len characters then return value is shortend to len characters.<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"50%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT LPAD(&#8216;hello&#8217;,7,&#8217;??&#8217;); -&gt;??hello mysql&gt; SELECT LPAD(&#8216;hello&#8217;,1,&#8217;??&#8217;); -&gt; h<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>LTRIM(str)<br \/>\n<\/strong>The LTRIM(str) function returns the string <em>str<\/em> with leading space characters removed. Here are the some example of the LTRIM(str) function:<br \/>\n<strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"48%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT LTRIM(&#8216;\u00a0 roseindia&#8217;); -&gt; &#8216;roseindia&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>MAKE_SET(bits,str1,str2,&#8230;)<br \/>\n<\/strong>The MAKE_SET(bits, str1, str2,..) function is returns a set value consisting of the strings that have the corresponding bit in bits set. str1 corresponds to bit 0, str2 to bit 1, and so on. NULL values in str1, str2, &#8230; are not appended to the result. Here are the some example of\u00a0 the MAKE_SET(bits, str1, str2,..) function: <strong>Example:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT MAKE_SET(2,&#8217;a&#8217;, &#8216;b&#8217;,&#8217;c&#8217;,&#8217;d&#8217;); -&gt; &#8216;b&#8217; mysql&gt; SELECT MAKE_SET(1|2,&#8217;hello&#8217;,&#8217;nice&#8217;,&#8217;comp&#8217;); -&gt; &#8216;hello,nice&#8217; mysql&gt; SELECT MAKE_SET(1|4,&#8217;good&#8217;,&#8217;nice&#8217;,null,&#8217;by&#8217;); -&gt; &#8216;good&#8217; mysql&gt; SELECT MAKE_SET(0, &#8216;1&#8217;,&#8217;2&#8242;, &#8216;3&#8217;, &#8216;4&#8217;); -&gt;&#8221;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>MID(str,pos,len)<br \/>\n<\/strong>The MID(str, pos, len) function is same as SUBSTRING(str,pos,len)<\/li>\n<li><strong>OCT(N)<br \/>\n<\/strong>The OCT(N) function is used to return a string representation of octal value of N, here N is a longlong (BIGINT) number<strong><br \/>\nExample:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\" height=\"2\">mysql&gt; SELECT OCT(12); -&gt; &#8217;14&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>OCTET_LENGTH(str)<br \/>\n<\/strong>The OCTET_LENGTH(str) function is same as LENGTH().<\/li>\n<li><strong>POSITION(substr IN str)<\/strong><br \/>\nThe POSITION(substr IN str) function is same as LOCATE (substr, str).<strong><br \/>\n<\/strong><\/li>\n<li><strong>REPEAT (str, count)<br \/>\n<\/strong>The REPEAT (str, count) function returns a string that consist a String <strong><em>str<\/em><\/strong> repeated of <strong><em>count<\/em><\/strong> times. But if <strong><em>count<\/em><\/strong> time is less than 1 than it returns an empty string.<\/p>\n<table border=\"0\" width=\"50%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT REPEAT(&#8216;Rose&#8217;, 3); -&gt;&#8217;RoseRoseRose&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>REPLACE (str, from_str, to_str)<br \/>\n<\/strong>The REPLACE (str, from_str, to_str) function returns the String <strong><em> str<\/em><\/strong> and in this String all occurrences of the String <strong><em> from_str<\/em><\/strong> is replaced by the String <strong><em>to_str<\/em><\/strong>. This function can perform a case-sensitive match when searching for <strong><em>from_str<\/em><\/strong>.<strong><br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"50%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT REPLACE (&#8216;www.roseindia.net&#8217;, &#8216;w&#8217;, &#8216;W&#8217;); -&gt;&#8217;WWW.roseindia.net&#8217;;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>REVERSE(str)<br \/>\n<\/strong>The REVERSE(str) function is used to return the reverse of String <strong><em>str<\/em><\/strong>.<strong><br \/>\nExample:<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"49%\">\n<tbody>\n<tr>\n<td bgcolor=\"#FFFFCC\" width=\"100%\">mysql&gt; SELECT REVERSE(&#8216;123&#8217;); -&gt; &#8216;321&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>RIGHT(str, len)<\/strong><br \/>\nThe RIGET(str, len) function returns the rightmost len characters from the String str. It return NULL if any argument is NULL.<br \/>\n<strong> Example :<\/strong><\/p>\n<table border=\"0\" width=\"46%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT RIGHT (&#8216;Roseindia&#8217;, 5); -&gt;&#8217;india&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>RPAD(str, len, padstr)<\/strong><br \/>\nThe RPAD(str, len, padstr) function returns the string str that is right padded with padstr string for length of len characters. But string str is longer than len characters then return value is shortend to len characters.<br \/>\n<strong>Example :<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"46%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT RPAD (&#8216;rose&#8217;, 7, &#8216;?&#8217;); -&gt;&#8217;rose???&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>RTRIM(str)<br \/>\n<\/strong>The RTRIM(str) function returns the String <strong><em> str<\/em><\/strong> with trailing space characters removed.<br \/>\n<strong>Example :<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"46%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT RTRIM (&#8216;rose\u00a0 &#8216;); -&gt;&#8217;rose&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>SPACE(N)<br \/>\n<\/strong>The SPACE(N) function returns a String that consist of N space characters.<br \/>\n<strong> Example :<\/strong><\/p>\n<table border=\"0\" width=\"34%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT SPACE(5); -&gt; &#8216;\u00a0\u00a0 &#8216;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>SUBSTRING(str,pos), SUBSTRING(str FROM pos), SUBSTRING(str,pos,len), SUBSTRING(str FROM pos FOR len)<br \/>\n<\/strong>The first two functions <strong>SUBSTRING(str,pos)<\/strong> and <strong> SUBSTRING(str FROM pos)<\/strong> return a substring from <em><strong> str<\/strong><\/em> String that is started at position <em><strong>pos<\/strong><\/em>. And the other two functions <strong>SUBSTRING(str,pos,len)<\/strong>, <strong> SUBSTRING(str FROM pos FOR len)<\/strong> return a substring, that?s length is <em><strong> len<\/strong><\/em> characters, from String <em><strong> str<\/strong><\/em> and its started at position <em><strong>pos<\/strong><\/em>.<br \/>\n<strong>Example :<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"39%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT SUBSTRING(&#8216;RoseIndia&#8217;,5); -&gt; &#8216;India&#8217; mysql&gt; SELECT SUBSTRING(&#8216;RoseIndia&#8217; FROM 5); -&gt; &#8216;India&#8217; mysql&gt; SELECT SUBSTRING(&#8216;RoseIndia&#8217;,5,3); -&gt; &#8216;Ind&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>UPPER(str)<br \/>\n<\/strong>The UPPER(str) function return the String <strong><em>str<\/em><\/strong>. And in this string all the characters are changed in the uppercase.<br \/>\n<strong>Example :<br \/>\n<\/strong><\/p>\n<table border=\"0\" width=\"38%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFCC\">\n<tbody>\n<tr>\n<td width=\"100%\">mysql&gt; SELECT UPPER(&#8216;roseindia&#8217;); -&gt;&#8217;ROSEINDIA&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>fonte: http:\/\/www.roseindia.net\/mysql\/mysql5\/mysql-string-function.shtml<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this section you can learn about the uses of MySQL String functions. These functions can be used to manipulate the string data. Here we have compiled the almost all String functions that you can use to learn more about string functions supported by MySQL.<\/p>\n","protected":false},"author":1,"featured_media":565,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-149","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","has-thumbnail"],"_links":{"self":[{"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/posts\/149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/comments?post=149"}],"version-history":[{"count":10,"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/posts\/149\/revisions"}],"predecessor-version":[{"id":571,"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/posts\/149\/revisions\/571"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/media\/565"}],"wp:attachment":[{"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/media?parent=149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/categories?post=149"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gnial.com.br\/gnialhelp\/wp-json\/wp\/v2\/tags?post=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}