Sie sind auf Seite 1von 1

MySQLCHEATSHEET:STRINGFUNCTIONS bymysqlbackupftp.

comwith

MEASUREMENT CONVERSION MODIFICATION


Returnastringcontainingbinaryrepresentationofa Returnnumericvalueofleftmostcharacter Returnconcatenatedstring Removetrailingspaces
number
ASCII('2')=50 CONCAT('My','S','QL')='MySQL' RTRIM('MySql')='MySql'
BIN(12)='1100' ASCII(2)=50 CONCAT('My',NULL,'QL')=NULL
ASCII('dx')=100 CONCAT(14.3)='14.3' Returnastringofthespecifiednumberofspaces
Returnlengthofargumentinbits
SPACE('6')=''
Returnthecharacterforeachnumberpassed Returnconcatenatewithseparator
BIT_LENGTH('MySql')=40
CHAR(77.3,121,83,81,'76,81.6')='MySQL' CONCAT_WS(',','My','Sql')='My,Sql' Returnthesubstringasspecified
Returnnumberofcharactersinargument
CHAR(45*256+45)=CHAR(45,45)='' CONCAT_WS(',','My',NULL,'Sql')='My,Sql' SUBSTRING=SUBSTR=MID('MySql',3)='Sql'
CHAR_LENGTH('MySql')=5 CHARSET(CHAR(X'65'USINGutf8))='utf8' SUBSTRING=SUBSTR=MID('MySql'FROM4)='ql'
Returnanumberformattedtospecifiednumberofdecimal
CHARACTER_LENGTH('MySql')=5 SUBSTRING=SUBSTR=MID('MySql',3,1)='S'
Decodeto/fromabase64string places
SUBSTRING=SUBSTR=MID('MySql',3)='Sql'
Returnthelengthofastringinbytes FORMAT(12332.123456,4)=12,332.1235
TO_BASE64('abc')='YWJj' SUBSTRING=SUBSTR=MID('MySql'FROM4FOR2)
LENGTH('')=2 FROM_BASE64('YWJj')='abc' FORMAT(12332.1,4)=12,332.1000 ='yS'
LENGTH('A')=1 FORMAT(12332.2,0)=12332.2
Convertstringornumbertoitshexadecimalrepresentation FORMAT(12332.2,2,'de_DE')=12.332,20 Removeleadingandtrailingspaces
OCTET_LENGTH('')=2
OCTET_LENGTH('X')=1 X'616263'='abc' TRIM('MySql')='MySql'
Insertasubstringatthespecifiedpositionuptothe
HEX('abc')=616263 specifiednumberofcharacters TRIM(LEADING'x'FROM'xxxSqlMy')='MySql'
Returnasoundexstring
HEX(255)='FF' TRIM(BOTH'My'FROM'MySqlMy')='Sql'
SOUNDEX('MySql')='M240' CONV(HEX(255),16,10)=255 INSERT('12345',3,2,'ABC')='12ABC5' TRIM(TRAILING'Sql'FROM'MySql')='My'
SOUNDEX('MySqlDatabase')='M24312' INSERT('12345',10,2,'ABC')='12345'
Converteachpairofhexadecimaldigitstoacharacter INSERT('12345',3,10,'ABC')='12ABC'
Comparetwostrings
STRCMP('A','A')=0
UNHEX('4D7953514C')='MySQL'
UNHEX('GG')=NULL
Returntheleftmostnumberofcharactersasspecified SETS
STRCMP('A','B')=1 UNHEX(HEX('abc'))='abc' LEFT('MySql',2)='My' Returnstringatindexnumber
STRCMP('B','A')=1 Returnthestringargument,leftpaddedwiththespecified ELT(1,'ej','Heja','hej','foo')='ej'
Returntheargumentinlowercase
string ELT(4,'ej','Heja','hej','foo')='foo'
LOWER('MYSQL')='mysql'
LPAD('Sql',2,':)')='Sq'
SEARCH LCASE('MYSQL')='mysql'
LPAD('Sql',4,':)')=':Sql'
Returnastringsuchthatforeverybitsetinthevaluebits,
yougetanonstringandforeveryunsetbit,yougetanoff
Loadthenamedfile LPAD('Sql',7,':)')=':):)Sql' string
Returntheindexofthefirstoccurrenceofsubstring
INSTR('MySql','Sql')=3 SETblob_col=LOAD_FILE('/tmp/picture') Removeleadingspaces EXPORT_SET(5,'Y','N',',',4)='Y,N,Y,N'
INSTR('Sql','MySql')=0 EXPORT_SET(6,'1','0',',',6)='0,1,1,0,0,0'
Returnastringcontainingoctalrepresentationofanumber LTRIM('MySql')='MySql'
Returnthepositionofthefirstoccurrenceofsubstring Returntheindex(position)ofthefirstargumentinthe
OCT(12)='14' Repeatastringthespecifiednumberoftimes subsequentarguments
LOCATE('Sql','MySqlSql')=3 Returncharactercodeforleftmostcharacterofthe REPEAT('MySQL',3)='MySQLMySQLMySQL'
LOCATE('xSql','MySql')=0 FIELD('ej','Hj','ej','Heja','hej','oo')=2
argument
LOCATE('Sql','MySqlSql',5)=6 Replaceoccurrencesofaspecifiedstring FIELD('fo','Hj','ej','Heja','hej','oo')=0
POSITION('Sql'IN'MySqlSql')=3 ORD('2')=50
REPLACE('NoSql','No','My')='MySql' Returntheindexpositionofthefirstargumentwithinthe
EscapetheargumentforuseinanSQLstatement secondargument
Patternmatchingusingregularexpressions
Reversethecharactersinastring
QUOTE('Don\'t!')='Don\'t!' FIND_IN_SET('b','a,b,c,d')=2
'abc'RLIKE'[az]+'=1
QUOTE(NULL)='NULL' REVERSE('MySql')='lqSyM' FIND_IN_SET('z','a,b,c,d')=0
'123'RLIKE'[az]+'=0
FIND_IN_SET('a,','a,b,c,d')=0
Converttouppercase Returnthespecifiedrightmostnumberofcharacters
Returnasubstringfromastringbeforethespecified
numberofoccurrencesofthedelimiter Returnasetofcommaseparatedstringsthathavethe
UPPER('mysql')='MYSQL' RIGHT('MySql',3)='Sql' correspondingbitinbitsset
SUBSTRING_INDEX('A:B:C',':',1)='A' UCASE('mysql')='MYSQL'
Returnsthestringargument,rightpaddedwiththe MAKE_SET(1,'a','b','c')='a'
SUBSTRING_INDEX('A:B:C',':',2)='A:B' specifiedstrin. MAKE_SET(1|4,'ab','cd','ef')='ab,ef'
SUBSTRING_INDEX('A:B:C',':',2)='B:C'
RPAD('Sql',2,':)')='Sq' MAKE_SET(1|4,'ab','cd',NULL,'ef')='ab'
RPAD('Sql',4,':)')='Sql:' MAKE_SET(0,'a','b','c')=''
RPAD('Sql',7,':)')='Sql:):)'

Das könnte Ihnen auch gefallen