mysql's built-in functions


mysql built-in function
<1> char_length (...) - Calculation of the string length
EG: SELECT CHAR_LENGTH ( 'Star') --4
<2> the concat ( 'Star', 'comeup', 'shta') - string concatenation
EG: SELECT the concat ( 'Star', 'comeup', 'shta') --starcomeupshta
<. 3> CONV () - hex conversion
eg: select conv ( 'a' , 16,2) --1010
<. 4> the format ()
EG: SELECT the format (11224.9,4) --11,224.9000

<. 5> iNSERT str inserted position specified character
eg: select insert ( 'star' , 1,1, 'w'); --- wtar
INSERT SELECT ( 'Star', 2,2 &, 'SW'); --- sswr
SELECT INSERT ( 'Star', 3,2-, 'MK'); --- STMK.
SELECT INSERT ( 'Star', 4,2 , 'lo');---stalo
select insert('star',2,2,'good'); --- sgoodr
INSERT SELECT ( 'Star', 2,2 &, 'G'); ---- SGR
<. 6> InStr () to find the location of characters in the string;
EG: SELECT InStr ( 'Star', 'A'); . 3 ----
<. 7> left (); obtaining the first few characters
EG: SELECT left ( 'Star', 2); --- ST
<. 8> right (); after obtaining several characters
eg: select right ( 'Star', 2) -Ar
<. 9> the substring () taken from several locations beginning several
EG: SELECT the substring ( 'Star', 2,2 &); --- TA
SELECT the substring ( 'iamasuperbboy',. 5 ); --- superbboy
SELECT the substring ( 'iamasuperbboy' from. 5); --- superbboy
SELECT the substring ( 'iamasuperbboy', 5,6); --- Superb
SELECT the substring ( 'Star', - 2); --- Ar
SELECT the substring ( 'iamasuperbboy '- 5.3); --- rbb
the substring SELECT ( 'for iamasuperbboy'from -5. 3); --- RBB
<10> LTRIM () remove the white space left
<11> rtrim () to the right of the blank is removed
<12> locate () Gets sequence index position
eg: select locate ( 'ar' , 'starstar', 1); --3 ( from a first position to find later)
SELECT the locate ( 'Ar', 'starstar',. 4); -. 7 (from 4th position looking onward)
<13 is> rEPEAT () is repeated several times in front of the string
EG: SELECT rEPEAT ( 'Star',. 5); --- starstarstarstarstar
<14> replace () replace
eg: select replace ( 'Star', 'TA', 'BG'); --- sbgr
SELECT Replace ( 'Star', 'TA', 'B'); --- SBR
SELECT Replace ( 'Star', 'TA', 'BGM '); sbgmr ---
<15> STRM ()
EG:select trim (leading 'a' from 'aaaaaaaaaaasdm'); - sdm remove left 'a'
select trim (both 'a' from 'aaaaaaaaaaasdmaaaaaaaaaaa'); --- sdm remove both sides of 'a'
SELECT TRIM (trailing 'a' from 'sdmaaaaaaaaaaa'); --- SDM removed right 'a'

Guess you like

Origin www.cnblogs.com/startl/p/12483010.html