1、字符串函數(shù)
ascii(str)??
返回字符串str的第一個(gè)字符的ascii值(str是空串時(shí)返回0)?
mysql> select ascii('2');?
-> 50?
mysql> select ascii(2);?
-> 50?
mysql> select ascii('dete');?
-> 100?
ord(str)??
如果字符串str句首是單字節(jié)返回與ascii()函數(shù)返回的相同值。
如果是一個(gè)多字節(jié)字符,以格式返回((first byte ascii code)*256+(second byte ascii code))[*256+third byte asciicode...]?
mysql> select ord('2');?
-> 50??
conv(n,from_base,to_base)??
對(duì)數(shù)字n進(jìn)制轉(zhuǎn)換,并轉(zhuǎn)換為字串返回(任何參數(shù)為null時(shí)返回null,進(jìn)制范圍為2-36進(jìn)制,當(dāng)to_base是負(fù)數(shù)時(shí)n作為有符號(hào)數(shù)否則作無(wú)符號(hào)數(shù),conv以64位點(diǎn)精度工作)?
mysql> select conv("a",16,2);?
-> '1010'
mysql> select conv("6e",18,8);?
-> '172'
mysql> select conv(-17,10,-18);?
-> '-h'
mysql> select conv(10+"10"+'10'+0xa,10,10);?
-> '40'?
bin(n)??
把n轉(zhuǎn)為二進(jìn)制值并以字串返回(n是bigint數(shù)字,等價(jià)于conv(n,10,2))?
mysql> select bin(12);?
-> '1100'?
oct(n)?
把n轉(zhuǎn)為八進(jìn)制值并以字串返回(n是bigint數(shù)字,等價(jià)于conv(n,10,8))?
mysql> select oct(12);?
-> '14'?
hex(n)?
把n轉(zhuǎn)為十六進(jìn)制并以字串返回(n是bigint數(shù)字,等價(jià)于conv(n,10,16))?
mysql> select hex(255);?
-> 'ff'?
char(n,...)?
返回由參數(shù)n,...對(duì)應(yīng)的ascii代碼字符組成的一個(gè)字串(參數(shù)是n,...是數(shù)字序列,null值被跳過(guò))??
mysql> select char(77,121,83,81,'76');?
-> 'mysql'
mysql> select char(77,77.3,'77.3');?
-> 'mmm'?
concat(str1,str2,...)??
把參數(shù)連成一個(gè)長(zhǎng)字符串并返回(任何參數(shù)是null時(shí)返回null)?
mysql> select concat('my', 's', 'ql');?
-> 'mysql'
mysql> select concat('my', null, 'ql');?
-> null
mysql> select concat(14.3);?
-> '14.3'?
length(str)??
octet_length(str)?
char_length(str)?
character_length(str)?
返回字符串str的長(zhǎng)度(對(duì)于多字節(jié)字符char_length僅計(jì)算一次)
mysql> select length('text');?
-> 4?
mysql> select octet_length('text');?
-> 4??
locate(substr,str)??
position(substr in str)?
返回字符串substr在字符串str第一次出現(xiàn)的位置(str不包含substr時(shí)返回0)?
mysql> select locate('bar', 'foobarbar');?
-> 4?
mysql> select locate('xbar', 'foobar');?
-> 0??
locate(substr,str,pos)?
返回字符串substr在字符串str的第pos個(gè)位置起第一次出現(xiàn)的位置(str不包含substr時(shí)返回0)?
mysql> select locate('bar', 'foobarbar',5);?
-> 7??
instr(str,substr)??
返回字符串substr在字符串str第一次出現(xiàn)的位置(str不包含substr時(shí)返回0)?
mysql> select instr('foobarbar', 'bar');?
-> 4?
mysql> select instr('xbar', 'foobar');?
-> 0???
lpad(str,len,padstr)??
用字符串padstr填補(bǔ)str左端直到字串長(zhǎng)度為len并返回?
mysql> select lpad('hi',4,'??');?
-> '??hi'?
rpad(str,len,padstr)??
用字符串padstr填補(bǔ)str右端直到字串長(zhǎng)度為len并返回?
mysql> select rpad('hi',5,'?');?
-> 'hi???'?
left(str,len)?
返回字符串str的左端len個(gè)字符?
mysql> select left('foobarbar', 5);?
-> 'fooba'?
right(str,len)??
返回字符串str的右端len個(gè)字符??
mysql> select right('foobarbar', 4);?
-> 'rbar'?
substring(str,pos,len)??
substring(str from pos for len)??
mid(str,pos,len)?
返回字符串str的位置pos起len個(gè)字符mysql> select substring('quadratically',5,6);?
-> 'ratica'?
substring(str,pos)??
substring(str from pos)?
返回字符串str的位置pos起的一個(gè)子串?
mysql> select substring('quadratically',5);?
-> 'ratically'
mysql> select substring('foobarbar' from 4);?
-> 'barbar'?
substring_index(str,delim,count)??
返回從字符串str的第count個(gè)出現(xiàn)的分隔符delim之后的子串
(count為正數(shù)時(shí)返回左端,否則返回右端子串)?
mysql> select substring_index('www.mysql.com', '.', 2);?
-> 'www.mysql'
mysql> select substring_index('www.mysql.com', '.', -2);?
-> 'mysql.com'?
ltrim(str)??
返回刪除了左空格的字符串str?
mysql> select ltrim('? barbar');?
-> 'barbar'?
rtrim(str)??
返回刪除了右空格的字符串str?
mysql> select rtrim('barbar?? ');?
-> 'barbar'?
trim([[both | leading | trailing] [remstr] from] str)??
返回前綴或后綴remstr被刪除了的字符串str(位置參數(shù)默認(rèn)both,remstr默認(rèn)值為空格)?
mysql> select trim('? bar?? ');?
-> 'bar'
mysql> select trim(leading 'x' from 'xxxbarxxx');?
-> 'barxxx'
mysql> select trim(both 'x' from 'xxxbarxxx');?
-> 'bar'
mysql> select trim(trailing 'xyz' from 'barxxyz');?
-> 'barx'?
soundex(str)??
返回str的一個(gè)同音字符串(聽(tīng)起來(lái)“大致相同”字符串有相同的
同音字符串,非數(shù)字字母字符被忽略,在a-z外的字母被當(dāng)作元音)?
mysql> select soundex('hello');?
-> 'h400'
mysql> select soundex('quadratically');?
-> 'q36324'?
space(n)??
返回由n個(gè)空格字符組成的一個(gè)字符串?
mysql> select space(6);?
-> '????? '?
replace(str,from_str,to_str)??
用字符串to_str替換字符串str中的子串from_str并返回?
mysql> select replace('www.mysql.com', 'w', 'ww');?
-> 'wwwwww.mysql.com'?
repeat(str,count)??
返回由count個(gè)字符串str連成的一個(gè)字符串(任何參數(shù)為null時(shí)
返回null,count<=0時(shí)返回一個(gè)空字符串)?
mysql> select repeat('mysql', 3);?
-> 'mysqlmysqlmysql'?
reverse(str)??
顛倒字符串str的字符順序并返回?
mysql> select reverse('abc');?
-> 'cba'?
insert(str,pos,len,newstr)??
把字符串str由位置pos起len個(gè)字符長(zhǎng)的子串替換為字符串
newstr并返回?
mysql> select insert('quadratic', 3, 4, 'what');?
-> 'quwhattic'?
elt(n,str1,str2,str3,...)??
返回第n個(gè)字符串(n小于1或大于參數(shù)個(gè)數(shù)返回null)?
mysql> select elt(1, 'ej', 'heja', 'hej', 'foo');?
-> 'ej'
mysql> select elt(4, 'ej', 'heja', 'hej', 'foo');?
-> 'foo'?
field(str,str1,str2,str3,...)??
返回str等于其后的第n個(gè)字符串的序號(hào)(如果str沒(méi)找到返回0)?
mysql> select field('ej', 'hej', 'ej', 'heja', 'hej',
'foo');?
-> 2?
mysql> select field('fo', 'hej', 'ej', 'heja', 'hej',
'foo');?
-> 0??
find_in_set(str,strlist)??
返回str在字符串集strlist中的序號(hào)(任何參數(shù)是null則返回
null,如果str沒(méi)找到返回0,參數(shù)1包含","時(shí)工作異常)?
mysql> select find_in_set('b','a,b,c,d');?
-> 2??
make_set(bits,str1,str2,...)?
把參數(shù)1的數(shù)字轉(zhuǎn)為二進(jìn)制,假如某個(gè)位置的二進(jìn)制位等于1,對(duì)應(yīng)
位置的字串選入字串集并返回(null串不添加到結(jié)果中)?
mysql> select make_set(1,'a','b','c');?
-> 'a'
mysql> select make_set(1 | 4,'hello','nice','world');?
-> 'hello,world'
mysql> select make_set(0,'a','b','c');?
-> ''?
export_set(bits,on,off,[separator,[number_of_bits]])??
按bits排列字符串集,只有當(dāng)位等于1時(shí)插入字串on,否則插入
off(separator默認(rèn)值",",number_of_bits參數(shù)使用時(shí)長(zhǎng)度不足補(bǔ)0
而過(guò)長(zhǎng)截?cái)???
mysql> select export_set(5,'y','n',',',4)?
-> y,n,y,n???
lcase(str)?
lower(str)??
返回小寫(xiě)的字符串str?
mysql> select lcase('quadratically');?
-> 'quadratically'?
ucase(str)??
upper(str)??
返回大寫(xiě)的字符串str?
mysql> select ucase('quadratically');?
-> 'quadratically'?
load_file(file_name)??
讀入文件并且作為一個(gè)字符串返回文件內(nèi)容(文件無(wú)法找到,路徑
不完整,沒(méi)有權(quán)限,長(zhǎng)度大于max_allowed_packet會(huì)返回null)?
mysql> update table_name set blob_column=load_file
("/tmp/picture") where id=1;??
2、數(shù)學(xué)函數(shù)
abs(n)?
返回n的絕對(duì)值?
mysql> select abs(2);???
-> 2???
mysql> select abs(-32);???
-> 32????
sign(n)?
返回參數(shù)的符號(hào)(為-1、0或1)?
mysql> select sign(-32);???
-> -1???
mysql> select sign(0);???
-> 0???
mysql> select sign(234);???
-> 1????
mod(n,m)???
取模運(yùn)算,返回n被m除的余數(shù)(同%操作符)???
mysql> select mod(234, 10);???
-> 4???
mysql> select 234 % 10;???
-> 4???
mysql> select mod(29,9);???
-> 2????
floor(n)?
返回不大于n的最大整數(shù)值?
mysql> select floor(1.23);???
-> 1???
mysql> select floor(-1.23);???
-> -2????
ceiling(n)?
返回不小于n的最小整數(shù)值?
mysql> select ceiling(1.23);???
-> 2???
mysql> select ceiling(-1.23);???
-> -1????
round(n,d)?
返回n的四舍五入值,保留d位小數(shù)(d的默認(rèn)值為0)?
mysql> select round(-1.23);???
-> -1???
mysql> select round(-1.58);???
-> -2???
mysql> select round(1.58);???
-> 2???
mysql> select round(1.298, 1);???
-> 1.3???
mysql> select round(1.298, 0);???
-> 1????
exp(n)?
返回值e的n次方(自然對(duì)數(shù)的底)?
mysql> select exp(2);???
-> 7.389056???
mysql> select exp(-2);???
-> 0.135335????
log(n)?
返回n的自然對(duì)數(shù)?
mysql> select log(2);???
-> 0.693147???
mysql> select log(-2);???
-> null????
log10(n)?
返回n以10為底的對(duì)數(shù)?
mysql> select log10(2);???
-> 0.301030???
mysql> select log10(100);???
-> 2.000000???
mysql> select log10(-100);???
-> null????
pow(x,y)???
power(x,y)???
返回值x的y次冪?
mysql> select pow(2,2);???
-> 4.000000???
mysql> select pow(2,-2);???
-> 0.250000?
sqrt(n)?
返回非負(fù)數(shù)n的平方根?
mysql> select sqrt(4);???
-> 2.000000???
mysql> select sqrt(20);???
-> 4.472136????
pi()???
返回圓周率??
mysql> select pi();???
-> 3.141593????
cos(n)?
返回n的余弦值?
mysql> select cos(pi());?
-> -1.000000????
sin(n)?
返回n的正弦值??
mysql> select sin(pi());???
-> 0.000000????
tan(n)?
返回n的正切值?
mysql> select tan(pi()+1);???
-> 1.557408????
acos(n)?
返回n反余弦(n是余弦值,在-1到1的范圍,否則返回null)?
mysql> select acos(1);???
-> 0.000000???
mysql> select acos(1.0001);???
-> null???
mysql> select acos(0);???
-> 1.570796????
asin(n)?
返回n反正弦值?
mysql> select asin(0.2);???
-> 0.201358???
mysql> select asin('foo');???
-> 0.000000????
atan(n)?
返回n的反正切值?
mysql> select atan(2);???
-> 1.107149???
mysql> select atan(-2);???
-> -1.107149???
atan2(x,y)???
返回2個(gè)變量x和y的反正切(類(lèi)似y/x的反正切,符號(hào)決定象限)?
mysql> select atan(-2,2);???
-> -0.785398???
mysql> select atan(pi(),0);???
-> 1.570796????
cot(n)?
返回x的余切?
mysql> select cot(12);???
-> -1.57267341???
mysql> select cot(0);???
-> null????
rand()?
rand(n)??
返回在范圍0到1.0內(nèi)的隨機(jī)浮點(diǎn)值(可以使用數(shù)字n作為初始值)
mysql> select rand();???
-> 0.5925???
mysql> select rand(20);???
-> 0.1811???
mysql> select rand(20);???
-> 0.1811???
mysql> select rand();???
-> 0.2079???
mysql> select rand();???
-> 0.7888????
degrees(n)?
把n從弧度變換為角度并返回?
mysql> select degrees(pi());???
-> 180.000000????
radians(n)?
把n從角度變換為弧度并返回??
mysql> select radians(90);???
-> 1.570796???
truncate(n,d)???
保留數(shù)字n的d位小數(shù)并返回?
mysql> select truncate(1.223,1);???
-> 1.2???
mysql> select truncate(1.999,1);???
-> 1.9???
mysql> select truncate(1.999,0);???
-> 1????
least(x,y,...)???
返回最小值(如果返回值被用在整數(shù)(實(shí)數(shù)或大小敏感字串)上下文或所有參數(shù)都是整數(shù)(實(shí)數(shù)或大小敏感字串)則他們作為整數(shù)(實(shí)數(shù)或大小敏感字串)比較,否則按忽略大小寫(xiě)的字符串被比較)?
mysql> select least(2,0);???
-> 0???
mysql> select least(34.0,3.0,5.0,767.0);???
-> 3.0???
mysql> select least("b","a","c");???
-> "a"????
greatest(x,y,...)???
返回最大值(其余同least())?
mysql> select greatest(2,0);???
-> 2???
mysql> select greatest(34.0,3.0,5.0,767.0);???
-> 767.0???
mysql> select greatest("b","a","c");???
-> "c"????
3、時(shí)期時(shí)間函數(shù)
dayofweek(date)???
返回日期date是星期幾(1=星期天,2=星期一,……7=星期六,odbc標(biāo)準(zhǔn))?
mysql> select dayofweek('1998-02-03');???
-> 3????
weekday(date)
返回日期date是星期幾(0=星期一,1=星期二,……6= 星期天)。
mysql> select weekday('1997-10-04 22:23:00');???
-> 5???
mysql> select weekday('1997-11-05');???
-> 2????
dayofmonth(date)??
返回date是一月中的第幾日(在1到31范圍內(nèi))???
mysql> select dayofmonth('1998-02-03');???
-> 3????
dayofyear(date)???
返回date是一年中的第幾日(在1到366范圍內(nèi))???
mysql> select dayofyear('1998-02-03');???
-> 34????
month(date)???
返回date中的月份數(shù)值???
mysql> select month('1998-02-03');???
-> 2????
dayname(date)???
返回date是星期幾(按英文名返回)?
mysql> select dayname("1998-02-05");???
-> 'thursday'????
monthname(date)??
返回date是幾月(按英文名返回)?
mysql> select monthname("1998-02-05");???
-> 'february'????
quarter(date)???
返回date是一年的第幾個(gè)季度???
mysql> select quarter('98-04-01');???
-> 2????
week(date,first)??
返回date是一年的第幾周(first默認(rèn)值0,first取值1表示周一是
周的開(kāi)始,0從周日開(kāi)始)?
mysql> select week('1998-02-20');???
-> 7???
mysql> select week('1998-02-20',0);???
-> 7???
mysql> select week('1998-02-20',1);???
-> 8????
year(date)???
返回date的年份(范圍在1000到9999)???
mysql> select year('98-02-03');???
-> 1998????
hour(time)?
返回time的小時(shí)數(shù)(范圍是0到23)??
mysql> select hour('10:05:03');???
-> 10????
minute(time)???
返回time的分鐘數(shù)(范圍是0到59)???
mysql> select minute('98-02-03 10:05:03');???
-> 5????
second(time)?
返回time的秒數(shù)(范圍是0到59)??
mysql> select second('10:05:03');???
-> 3????
period_add(p,n)???
增加n個(gè)月到時(shí)期p并返回(p的格式y(tǒng)ymm或yyyymm)???
mysql> select period_add(9801,2);???
-> 199803????
period_diff(p1,p2)???
返回在時(shí)期p1和p2之間月數(shù)(p1和p2的格式y(tǒng)ymm或yyyymm)?
mysql> select period_diff(9802,199703);???
-> 11???
date_add(date,interval expr type)?
date_sub(date,interval expr type)???
adddate(date,interval expr type)???
subdate(date,interval expr type)?
對(duì)日期時(shí)間進(jìn)行加減法運(yùn)算?
(adddate()和subdate()是date_add()和date_sub()的同義詞,也
可以用運(yùn)算符+和-而不是函數(shù)?
date是一個(gè)datetime或date值,expr對(duì)date進(jìn)行加減法的一個(gè)表
達(dá)式字符串type指明表達(dá)式expr應(yīng)該如何被解釋?
[type值 含義 期望的expr格式]:?
second 秒 seconds???
minute 分鐘 minutes???
hour 時(shí)間 hours???
day 天 days???
month 月 months???
year 年 years???
minute_second 分鐘和秒 "minutes:seconds"???
hour_minute 小時(shí)和分鐘 "hours:minutes"???
day_hour 天和小時(shí) "days hours"???
year_month 年和月 "years-months"???
hour_second 小時(shí), 分鐘, "hours:minutes:seconds"???
day_minute 天, 小時(shí), 分鐘 "days hours:minutes"???
day_second 天, 小時(shí), 分鐘, 秒 "days
hours:minutes:seconds"
expr中允許任何標(biāo)點(diǎn)做分隔符,如果所有是date值時(shí)結(jié)果是一個(gè)
date值,否則結(jié)果是一個(gè)datetime值)?
如果type關(guān)鍵詞不完整,則mysql從右端取值,day_second因?yàn)槿?br/>少小時(shí)分鐘等于minute_second)?
如果增加month、year_month或year,天數(shù)大于結(jié)果月份的最大天
數(shù)則使用最大天數(shù))???
mysql> select "1997-12-31 23:59:59" + interval 1 second;?
-> 1998-01-01 00:00:00???
mysql> select interval 1 day + "1997-12-31";???
-> 1998-01-01???
mysql> select "1998-01-01" - interval 1 second;???
-> 1997-12-31 23:59:59???
mysql> select date_add("1997-12-31 23:59:59",interval 1
second);???
-> 1998-01-01 00:00:00???
mysql> select date_add("1997-12-31 23:59:59",interval 1
day);???
-> 1998-01-01 23:59:59???
mysql> select date_add("1997-12-31 23:59:59",interval
"1:1" minute_second);???
-> 1998-01-01 00:01:00???
mysql> select date_sub("1998-01-01 00:00:00",interval "1
1:1:1" day_second);???
-> 1997-12-30 22:58:59???
mysql> select date_add("1998-01-01 00:00:00", interval "-1
10" day_hour);?
-> 1997-12-30 14:00:00???
mysql> select date_sub("1998-01-02", interval 31 day);???
-> 1997-12-02???
mysql> select extract(year from "1999-07-02");???
-> 1999???
mysql> select extract(year_month from "1999-07-02
01:02:03");???
-> 199907???
mysql> select extract(day_minute from "1999-07-02
01:02:03");???
-> 20102????
to_days(date)???
返回日期date是西元0年至今多少天(不計(jì)算1582年以前)?
mysql> select to_days(950501);???
-> 728779???
mysql> select to_days('1997-10-07');???
-> 729669????
from_days(n)???
給出西元0年至今多少天返回date值(不計(jì)算1582年以前)??
mysql> select from_days(729669);???
-> '1997-10-07'????
date_format(date,format)???
根據(jù)format字符串格式化date值?
(在format字符串中可用標(biāo)志符:?
%m 月名字(january……december)???
%w 星期名字(sunday……saturday)???
%d 有英語(yǔ)前綴的月份的日期(1st, 2nd, 3rd, 等等。)???
%y 年, 數(shù)字, 4 位???
%y 年, 數(shù)字, 2 位???
%a 縮寫(xiě)的星期名字(sun……sat)???
%d 月份中的天數(shù), 數(shù)字(00……31)???
%e 月份中的天數(shù), 數(shù)字(0……31)???
%m 月, 數(shù)字(01……12)???
%c 月, 數(shù)字(1……12)???
%b 縮寫(xiě)的月份名字(jan……dec)???
%j 一年中的天數(shù)(001……366)???
%h 小時(shí)(00……23)???
%k 小時(shí)(0……23)???
%h 小時(shí)(01……12)???
%i 小時(shí)(01……12)???
%l 小時(shí)(1……12)???
%i 分鐘, 數(shù)字(00……59)???
%r 時(shí)間,12 小時(shí)(hh:mm:ss [ap]m)???
%t 時(shí)間,24 小時(shí)(hh:mm:ss)???
%s 秒(00……59)???
%s 秒(00……59)???
%p am或pm???
%w 一個(gè)星期中的天數(shù)(0=sunday ……6=saturday )???
%u 星期(0……52), 這里星期天是星期的第一天???
%u 星期(0……52), 這里星期一是星期的第一天???
%% 字符% )?
mysql> select date_format('1997-10-04 22:23:00','%w %m %
y');???
-> 'saturday october 1997'???
mysql> select date_format('1997-10-04 22:23:00','%h:%i:%
s');???
-> '22:23:00'???
mysql> select date_format('1997-10-04 22:23:00','%d %y %a
%d %m %b %j');???
-> '4th 97 sat 04 10 oct 277'???
mysql> select date_format('1997-10-04 22:23:00','%h %k %i
%r %t %s %w');???
-> '22 22 10 10:23:00 pm 22:23:00 00 6'????
time_format(time,format)?
和date_format()類(lèi)似,但time_format只處理小時(shí)、分鐘和秒(其
余符號(hào)產(chǎn)生一個(gè)null值或0)??
curdate()????
current_date()?
以'yyyy-mm-dd'或yyyymmdd格式返回當(dāng)前日期值(根據(jù)返回值所
處上下文是字符串或數(shù)字)???
mysql> select curdate();???
-> '1997-12-15'???
mysql> select curdate() + 0;???
-> 19971215????
curtime()???
current_time()?
以'hh:mm:ss'或hhmmss格式返回當(dāng)前時(shí)間值(根據(jù)返回值所處上
下文是字符串或數(shù)字)?????
mysql> select curtime();???
-> '23:50:26'???
mysql> select curtime() + 0;???
-> 235026????
now()??
sysdate()??
current_timestamp()?
以'yyyy-mm-dd hh:mm:ss'或yyyymmddhhmmss格式返回當(dāng)前日期
時(shí)間(根據(jù)返回值所處上下文是字符串或數(shù)字)????
mysql> select now();???
-> '1997-12-15 23:50:26'???
mysql> select now() + 0;???
-> 19971215235026????
unix_timestamp()???
unix_timestamp(date)???
返回一個(gè)unix時(shí)間戳(從'1970-01-01 00:00:00'gmt開(kāi)始的秒
數(shù),date默認(rèn)值為當(dāng)前時(shí)間)?
mysql> select unix_timestamp();???
-> 882226357???
mysql> select unix_timestamp('1997-10-04 22:23:00');???
-> 875996580????
from_unixtime(unix_timestamp)???
以'yyyy-mm-dd hh:mm:ss'或yyyymmddhhmmss格式返回時(shí)間戳的
值(根據(jù)返回值所處上下文是字符串或數(shù)字)????
mysql> select from_unixtime(875996580);???
-> '1997-10-04 22:23:00'???
mysql> select from_unixtime(875996580) + 0;???
-> 19971004222300????
from_unixtime(unix_timestamp,format)??
以format字符串格式返回時(shí)間戳的值?
mysql> select from_unixtime(unix_timestamp(),'%y %d %m %
h:%i:%s %x');???
-> '1997 23rd december 03:43:30 x'????
sec_to_time(seconds)???
以'hh:mm:ss'或hhmmss格式返回秒數(shù)轉(zhuǎn)成的time值(根據(jù)返回值所處上下文是字符串或數(shù)字)????
mysql> select sec_to_time(2378);???
-> '00:39:38'???
mysql> select sec_to_time(2378) + 0;???
-> 3938????
time_to_sec(time)???
返回time值有多少秒???
mysql> select time_to_sec('22:23:00');???
-> 80580???
mysql> select time_to_sec('00:39:38');???
-> 2378?
轉(zhuǎn)換函數(shù)
cast
用法:cast(字段 as 數(shù)據(jù)類(lèi)型) [當(dāng)然是否可以成功轉(zhuǎn)換,還要看數(shù)據(jù)類(lèi)型強(qiáng)制轉(zhuǎn)化時(shí)注意的問(wèn)題]
實(shí)例:select cast(a as unsigned) as b from cardserver where order by b desc;
convert:
用法:convert(字段,數(shù)據(jù)類(lèi)型)
實(shí)例:select convert(a ,unsigned) as b from cardserver where order by b desc;








暫無(wú)數(shù)據(jù)