Mysql 函数学习

SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL
-> 0,0,1    
SELECT IF(0.1,1,0)
->0
SELECT IF(0.1<>0,1,0)
->1
SELECT CONCAT_WS(',','First name','Second name','Last Name');
->'Firstname,Second name,Last Name'
SELECT ELT(1,'ej','Heja','hej','foo');
->'ej'
SELECT FIELD('ej','Hej','ej','Heja','hej','foo');
->2
SELECT FIND_IN_SET('b','a,b,c,d');
->2
INSERT(str,pos,len,newstr)返回字符串str,其子字符串起始于pos位置和长期被字符串newstr取代的len字符
SELECT INSERT('Quadratic',3,4,'What');
->'QuWhattic'
INSTR(str,substr)返回字符串的第一个出现位置
SELECT INSTR('foobarbar','bar');
->4
LEFT(str,len)返回从字符串str开始的len最左字符
SELECT LEFT('foobarbar',5);
->'fooba'
LOCATE(substr,str),LOCATE(substr,str,pos)
LPAD(str,len,padstr)返回字符串str,其左边由字符串padstr填补len字符长度,假如str长度大于len,则返回值缩短至len字符
SELECT LPAD('hi',4,'??')
->'??hi'
SELECT LPAD('hi',1,'??')
->'h'
SELECT TRIM('   bar   ');
->'bar'
SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx')
->'barxxx'
SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx')
->'bar'
SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz')
->'barx'
SELECT MAKEDATE(2009,31),MAKEDATE(2009,32);
->'2009-01-31','2009-02-01';
SELECT STR_TO_DATE('04/31/2009','%m/%d/%Y');
->'2009-04-31'

你可能感兴趣的:(mysql,数据库,函数,学习,休闲)