<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] ## 1.字符串函數 ### 1.1 ascii(str) 返回字符串str的第一個字符的ascii值(str是空串時返回0) ~~~ mysql> select ascii('2');   -> 50 mysql> select ascii(2);   -> 50 mysql> select ascii('dete');   -> 100 ~~~ ### 1.2 ord(str) 如果字符串str句首是單字節返回與ascii()函數返回的相同值。 如果是一個多字節字符,以格式返回((first byte ascii code)*256+(second byte ascii code))[*256+third byte asciicode...] ~~~ mysql> select ord('2');   -> 50 ~~~ ### 1.3 conv(n,from_base,to_base) 對數字n進制轉換,并轉換為字串返回(任何參數為null時返回null,進制范圍為2-36進制,當to_base是負數時n作為有符號數否則作無符號數,conv以64位點精度工作) ~~~ 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' ~~~ ### 1.4 bin(n) 把n轉為二進制值并以字串返回(n是bigint數字,等價于conv(n,10,2)) ~~~ mysql> select bin(12);   -> '1100' ~~~ ### 1.5 oct(n) 把n轉為八進制值并以字串返回(n是bigint數字,等價于conv(n,10,8)) ~~~ mysql> select oct(12);   -> '14' ~~~ ### 1.6 hex(n) 把n轉為十六進制并以字串返回(n是bigint數字,等價于conv(n,10,16)) ~~~ mysql> select hex(255);   -> 'ff' ~~~ ### 1.7 char(n,...) 返回由參數n,...對應的ascii代碼字符組成的一個字串(參數是n,...是數字序列,null值被跳過) ~~~ mysql> select char(77,121,83,81,'76');   -> 'mysql' mysql> select char(77,77.3,'77.3');   -> 'mmm' ~~~ ### 1.8 concat(str1,str2,...) 把參數連成一個長字符串并返回(任何參數是null時返回null) ~~~ mysql> select concat('my', 's', 'ql');   -> 'mysql' mysql> select concat('my', null, 'ql');   -> null mysql> select concat(14.3);   -> '14.3' ~~~ ### 1.9 length(str) octet_length(str) char_length(str) character_length(str) 返回字符串str的長度(對于多字節字符char_length僅計算一次) ~~~ mysql> select length('text');   -> 4 mysql> select octet_length('text');   -> 4 ~~~ ### 1.10 locate(substr,str) position(substr in str) 返回字符串substr在字符串str第一次出現的位置(str不包含substr時返回0) ~~~ mysql> select locate('bar', 'foobarbar');   -> 4 mysql> select locate('xbar', 'foobar');   -> 0 ~~~ ### 1.11 locate(substr,str,pos) 返回字符串substr在字符串str的第pos個位置起第一次出現的位置(str不包含substr時返回0) ~~~ mysql> select locate('bar', 'foobarbar',5);   -> 7 ~~~ ### 1.12 instr(str,substr) 返回字符串substr在字符串str第一次出現的位置(str不包含substr時返回0) ~~~ mysql> select instr('foobarbar', 'bar');   -> 4 mysql> select instr('xbar', 'foobar');   -> 0 ~~~ ### 1.13 lpad(str,len,padstr) 用字符串padstr填補str左端直到字串長度為len并返回 ~~~ mysql> select lpad('hi',4,'??');   -> '??hi' ~~~ ### 1.14 rpad(str,len,padstr) 用字符串padstr填補str右端直到字串長度為len并返回 ~~~ mysql> select rpad('hi',5,'?');   -> 'hi???' ~~~ ### 1.15 left(str,len) 返回字符串str的左端len個字符 ~~~ mysql> select left('foobarbar', 5);   -> 'fooba' ~~~ ### 1.16 right(str,len) 返回字符串str的右端len個字符 ~~~ mysql> select right('foobarbar', 4);   -> 'rbar' ~~~ ### 1.17 substring(str,pos,len) mid(str,pos,len) 返回字符串str的位置pos起len個字符 ~~~ mysql> select substring('quadratically',5,6);   -> 'ratica' ~~~ ### 1.18 substring(str,pos) substring(str from pos) 返回字符串str的位置pos起的一個子串 ~~~ mysql> select substring('quadratically',5);   -> 'ratically' mysql> select substring('foobarbar' from 4);   -> 'barbar' ~~~ ### 1.19 substring_index(str,delim,count) 返回從字符串str的第count個出現的分隔符delim之后的子串 (count為正數時返回左端,否則返回右端子串) ~~~ mysql> select substring_index('www.mysql.com', '.', 2);   -> 'www.mysql' mysql> select substring_index('www.mysql.com', '.', -2);   -> 'mysql.com' ~~~ ### 1.20 ltrim(str) 返回刪除了左空格的字符串str ~~~ mysql> select ltrim(' barbar');   -> 'barbar' ~~~ ### 1.21 rtrim(str) 返回刪除了右空格的字符串str ~~~ mysql> select rtrim('barbar ');   -> 'barbar' ~~~ ### 1.22 trim([[both | leading | trailing] [remstr] from] str) 返回前綴或后綴remstr被刪除了的字符串str(位置參數默認both,remstr默認值為空格) ~~~ 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' ~~~ ### 1.23 soundex(str) 返回str的一個同音字符串(聽起來“大致相同”字符串有相同的同音字符串,非數字字母字符被忽略,在a-z外的字母被當作元音) ~~~ mysql> select soundex('hello');   -> 'h400' mysql> select soundex('quadratically');   -> 'q36324' ~~~ ### 1.24 space(n) 返回由n個空格字符組成的一個字符串 ~~~ mysql> select space(6);   -> ' ' ~~~ ### 1.25 replace(str,from_str,to_str) 用字符串to_str替換字符串str中的所有子串from_str并返回 ~~~ mysql> select replace('www.mysql.com', 'w', 'ww');   -> 'wwwwww.mysql.com' ~~~ ### 1.25 repeat(str,count) 返回由count個字符串str連成的一個字符串(任何參數為null時,返回null,count<=0時返回一個空字符串) ~~~ mysql> select repeat('mysql', 3);   -> 'mysqlmysqlmysql' ~~~ ### 1.26 reverse(str) 顛倒字符串str的字符順序并返回 ~~~ mysql> select reverse('abc');   -> 'cba' ~~~ ### 1.26 insert(str,pos,len,newstr) 把字符串str由位置pos起len個字符長的子串替換為字符串newstr并返回 ~~~ mysql> select insert('quadratic', 3, 4, 'what');   -> 'quwhattic' ~~~ ### 1.27 elt(n,str1,str2,str3,...) 返回第n個字符串(n小于1或大于參數個數返回null) ~~~ mysql> select elt(1, 'ej', 'heja', 'hej', 'foo');   -> 'ej' mysql> select elt(4, 'ej', 'heja', 'hej', 'foo');   -> 'foo' ~~~ ### 1.28 field(str,str1,str2,str3,...) 返回str等于其后的第n個字符串的序號(如果str沒找到返回0) ~~~ mysql> select field('ej', 'hej', 'ej', 'heja', 'hej', 'foo');   -> 2 mysql> select field('fo', 'hej', 'ej', 'heja', 'hej', 'foo');   -> 0 ~~~ ### 1.29 find_in_set(str,strlist) 返回str在字符串集strlist中的序號(任何參數是null則返回null,如果str沒找到返回0,參數1包含","時工作異常) ~~~ mysql> select find_in_set('b','a,b,c,d');   -> 2 ~~~ ### 1.30 make_set(bits,str1,str2,...) 把參數1的數字轉為二進制,假如某個位置的二進制位等于1,對應位置的字串選入字串集并返回(null串不添加到結果中) ~~~ 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');   -> '' ~~~ ### 1.31 export_set(bits,on,off,[separator,[number_of_bits]]) 按bits排列字符串集,只有當位等于1時插入字串on,否則插入 off(separator默認值",",number_of_bits參數使用時長度不足補0 而過長截斷) ~~~ mysql> select export_set(5,'y','n',',',4)   -> y,n,y,n ~~~ ### 1.41 lcase(str) lower(str) 返回小寫的字符串str ~~~ mysql> select lcase('quadratically');   -> 'quadratically' ~~~ ### 1.42 ucase(str) upper(str) 返回大寫的字符串str ~~~ mysql> select ucase('quadratically');   -> 'quadratically' ~~~ ### 1.43 load_file(file_name) 讀入文件并且作為一個字符串返回文件內容(文件無法找到,路徑不完整,沒有權限,長度大于max_allowed_packet會返回null) ~~~ mysql> update table_name set blob_column=load_file ("/tmp/picture") where id=1; ~~~ ## 2. 數學函數 ### 2.1 abs(n) 返回n的絕對值 ~~~ mysql> select abs(2);   -> 2 mysql> select abs(-32);   -> 32 ~~~ ### 2.2 sign(n) 返回參數的符號(為-1、0或1) ~~~ mysql> select sign(-32);   -> -1 mysql> select sign(0);   -> 0 mysql> select sign(234);   -> 1 ~~~ ### 2.3 mod(n,m) 取模運算,返回n被m除的余數(同%操作符) ~~~ mysql> select mod(234, 10);   -> 4 mysql> select 234 % 10;   -> 4 mysql> select mod(29,9);   -> 2 ~~~ ### 2.4 floor(n) 返回不大于n的最大整數值 ~~~ mysql> select floor(1.23);   -> 1 mysql> select floor(-1.23);   -> -2 ~~~ ### 2.5 ceiling(n) 返回不小于n的最小整數值 ~~~ mysql> select ceiling(1.23);   -> 2 mysql> select ceiling(-1.23);   -> -1 ~~~ ### 2.6 round(n,d) 返回n的四舍五入值,保留d位小數(d的默認值為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 ~~~ ### 2.7 exp(n) 返回值e的n次方(自然對數的底) ~~~ mysql> select exp(2);   -> 7.389056 mysql> select exp(-2);   -> 0.135335 ~~~ ### 2.8 log(n) 返回n的自然對數 ~~~ mysql> select log(2);   -> 0.693147 mysql> select log(-2);   -> null ~~~ ### 2.9 log10(n) 返回n以10為底的對數 ~~~ mysql> select log10(2);   -> 0.301030 mysql> select log10(100);   -> 2.000000 mysql> select log10(-100);   -> null ~~~ ### 2.10 pow(x,y) power(x,y)  返回值x的y次冪 ~~~ mysql> select pow(2,2);   -> 4.000000 mysql> select pow(2,-2);   -> 0.250000 ~~~ ### 2.11 sqrt(n)  返回非負數n的平方根 ~~~ mysql> select sqrt(4);   -> 2.000000 mysql> select sqrt(20);   -> 4.472136 ~~~ ### 2.12 pi()  返回圓周率 ~~~ mysql> select pi();   -> 3.141593 ~~~ ### 2.13 cos(n)  返回n的余弦值 ~~~ mysql> select cos(pi());   -> -1.000000 ~~~ ### 2.14 sin(n)  返回n的正弦值 ~~~ mysql> select sin(pi());   -> 0.000000 ~~~ ### 2.25 tan(n) 返回n的正切值 ~~~ mysql> select tan(pi()+1);   -> 1.557408 ~~~ ### 2.26 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 ~~~ ### 2.27 asin(n) 返回n反正弦值 ~~~ mysql> select asin(0.2);   -> 0.201358 mysql> select asin('foo');   -> 0.000000 ~~~ ### 2.28 atan(n) 返回n的反正切值 ~~~ mysql> select atan(2);   -> 1.107149 mysql> select atan(-2);   -> -1.107149 ~~~ ### 2.29 atan2(x,y)  返回2個變量x和y的反正切(類似y/x的反正切,符號決定象限) ~~~ mysql> select atan(-2,2);   -> -0.785398 mysql> select atan(pi(),0);   -> 1.570796 ~~~ ### 2.30 cot(n) 返回x的余切 ~~~ mysql> select cot(12);   -> -1.57267341 mysql> select cot(0);   -> null ~~~ ### 2.31 rand() rand(n) 返回在范圍0到1.0內的隨機浮點值(可以使用數字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 ~~~ ### 2.32 degrees(n) 把n從弧度變換為角度并返回 ~~~ mysql> select degrees(pi());   -> 180.000000 ~~~ ### 2.33 radians(n) 把n從角度變換為弧度并返回 ~~~ mysql> select radians(90);   -> 1.570796 ~~~ ### 2.34 truncate(n,d) 保留數字n的d位小數并返回 ~~~ mysql> select truncate(1.223,1);   -> 1.2 mysql> select truncate(1.999,1);   -> 1.9 mysql> select truncate(1.999,0);   -> 1 ~~~ ### 2.35 least(x,y,...) 返回最小值(如果返回值被用在整數(實數或大小敏感字串)上下文或所有參數都是整數(實數或大小敏感字串)則他們作為整數(實數或大小敏感字串)比較,否則按忽略大小寫的字符串被比較) ~~~ 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" ~~~ ### 2.36 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. 時期時間函數 ### 3.1 dayofweek(date) 返回日期date是星期幾(1=星期天,2=星期一,……7=星期六,odbc標準) ~~~ mysql> select dayofweek('1998-02-03');   -> 3 ~~~ ### 3.2 weekday(date) 返回日期date是星期幾(0=星期一,1=星期二,……6= 星期天)。 ~~~ mysql> select weekday('1997-10-04 22:23:00');   -> 5 mysql> select weekday('1997-11-05');   -> 2 ~~~ ### 3.3 dayofmonth(date) 返回date是一月中的第幾日(在1到31范圍內) ~~~ mysql> select dayofmonth('1998-02-03');   -> 3 ~~~ ### 3.4 dayofyear(date) 返回date是一年中的第幾日(在1到366范圍內) ~~~ mysql> select dayofyear('1998-02-03');   -> 34 ~~~ ### 3.5 month(date) 返回date中的月份數值 ~~~ mysql> select month('1998-02-03');   -> 2 ~~~ ### 3.6 dayname(date) 返回date是星期幾(按英文名返回) ~~~ mysql> select dayname("1998-02-05");   -> 'thursday' ~~~ ### 3.7 monthname(date) 返回date是幾月(按英文名返回) ~~~ mysql> select monthname("1998-02-05");   -> 'february' ~~~ ### 3.8 quarter(date) 返回date是一年的第幾個季度 ~~~ mysql> select quarter('98-04-01');   -> 2 ~~~ ### 3.9 week(date,first) 返回date是一年的第幾周(first默認值0,first取值1表示周一是 周的開始,0從周日開始) ~~~ mysql> select week('1998-02-20');   -> 7 mysql> select week('1998-02-20',0);   -> 7 mysql> select week('1998-02-20',1);   -> 8 ~~~ ### 3.10 year(date) 返回date的年份(范圍在1000到9999) ~~~ mysql> select year('98-02-03');   -> 1998 ~~~ ### 3.11 hour(time) 返回time的小時數(范圍是0到23) ~~~ mysql> select hour('10:05:03');   -> 10 ~~~ ### 3.12 minute(time) 返回time的分鐘數(范圍是0到59) ~~~ mysql> select minute('98-02-03 10:05:03');   -> 5 ~~~ ### 3.14 second(time) 返回time的秒數(范圍是0到59) ~~~ mysql> select second('10:05:03');   -> 3 ~~~ ### 3.15 period_add(p,n) 增加n個月到時期p并返回(p的格式yymm或yyyymm) ~~~ mysql> select period_add(9801,2);   -> 199803 ~~~ ### 3.16 period_diff(p1,p2) 返回在時期p1和p2之間月數(p1和p2的格式yymm或yyyymm) ~~~ mysql> select period_diff(9802,199703);   -> 11 ~~~ ### 3.17 時間加減法 ~~~ date_add(date,interval expr type) date_sub(date,interval expr type) adddate(date,interval expr type) subdate(date,interval expr type) ~~~ (adddate()和subdate()是date_add()和date_sub()的同義詞,也可以用運算符+和-而不是函數 ,date是一個datetime或date值,expr對date進行加減法的一個表達式字符串type指明表達式expr應該如何被解釋  [type值 含義 期望的expr格式]: >  second 秒 seconds >  minute 分鐘 minutes >  hour 時間 hours >  day 天 days >  month 月 months >  year 年 years >  minute_second 分鐘和秒 "minutes:seconds" >  hour_minute 小時和分鐘 "hours:minutes" >  day_hour 天和小時 "days hours" >  year_month 年和月 "years-months" >  hour_second 小時, 分鐘, "hours:minutes:seconds" >  day_minute 天, 小時, 分鐘 "days hours:minutes" >  day_second 天, 小時, 分鐘, 秒 "days > hours:minutes:seconds" >  expr中允許任何標點做分隔符,如果所有是date值時結果是一個 > date值,否則結果是一個datetime值) >  如果type關鍵詞不完整,則mysql從右端取值,day_second因為缺 > 少小時分鐘等于minute_second) >  如果增加month、year_month或year,天數大于結果月份的最大天 > 數則使用最大天數) ~~~ 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 ~~~ ### 3.18 extract 截取時間 ~~~ 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 ~~~ ### 3.19 to_days(date) 返回日期date是西元0年至今多少天(不計算1582年以前) ~~~ mysql> select to_days(950501);   -> 728779 mysql> select to_days('1997-10-07');   -> 729669 ~~~ ### 3.20 from_days(n) 給出西元0年至今多少天返回date值(不計算1582年以前) ~~~ mysql> select from_days(729669);   -> '1997-10-07' ~~~ ### 3.21 date_format(date,format) 根據format字符串格式化date值 > * 在format字符串中可用標志符: >  %m 月名字(january……december) >  %w 星期名字(sunday……saturday) >  %d 有英語前綴的月份的日期(1st, 2nd, 3rd, 等等。) >  %y 年, 數字, 4 位 >  %y 年, 數字, 2 位 >  %a 縮寫的星期名字(sun……sat) >  %d 月份中的天數, 數字(00……31) >  %e 月份中的天數, 數字(0……31) >  %m 月, 數字(01……12) >  %c 月, 數字(1……12) >  %b 縮寫的月份名字(jan……dec) >  %j 一年中的天數(001……366) >  %h 小時(00……23) >  %k 小時(0……23) >  %h 小時(01……12) >  %i 小時(01……12) >  %l 小時(1……12) >  %i 分鐘, 數字(00……59) >  %r 時間,12 小時(hh:mm:ss [ap]m) >  %t 時間,24 小時(hh:mm:ss) >  %s 秒(00……59) >  %s 秒(00……59) >  %p am或pm >  %w 一個星期中的天數(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' ~~~ ### 3.32time_format(time,format)  和date_format()類似,但time_format只處理小時、分鐘和秒(其 余符號產生一個null值或0) ### 3.33 curdate() current_date()  以'yyyy-mm-dd'或yyyymmdd格式返回當前日期值(根據返回值所處上下文是字符串或數字) ~~~ mysql> select curdate();   -> '1997-12-15' mysql> select curdate() + 0;   -> 19971215 ~~~ ### 3.34 curtime() current_time()  以'hh:mm:ss'或hhmmss格式返回當前時間值(根據返回值所處上 下文是字符串或數字) ~~~ mysql> select curtime();   -> '23:50:26' mysql> select curtime() + 0;   -> 235026 ~~~ ### 3.35 now() sysdate() current_timestamp()  以'yyyy-mm-dd hh:mm:ss'或yyyymmddhhmmss格式返回當前日期 時間(根據返回值所處上下文是字符串或數字) ~~~ mysql> select now();   -> '1997-12-15 23:50:26' mysql> select now() + 0;   -> 19971215235026 ~~~ ### 3.36 unix_timestamp() unix_timestamp(date) 返回一個unix時間戳(從'1970-01-01 00:00:00'gmt開始的秒數,date默認值為當前時間) ~~~ mysql> select unix_timestamp();   -> 882226357 mysql> select unix_timestamp('1997-10-04 22:23:00');   -> 875996580 ~~~ ### 3.37 from_unixtime(unix_timestamp) 以'yyyy-mm-dd hh:mm:ss'或yyyymmddhhmmss格式返回時間戳的 值(根據返回值所處上下文是字符串或數字) ~~~ mysql> select from_unixtime(875996580);   -> '1997-10-04 22:23:00' mysql> select from_unixtime(875996580) + 0;   -> 19971004222300 ~~~ ### 3.38 from_unixtime(unix_timestamp,format) 以format字符串格式返回時間戳的值 ~~~ mysql> select from_unixtime(unix_timestamp(),'%y %d %m % h:%i:%s %x');   -> '1997 23rd december 03:43:30 x' ~~~ ### 3.39 sec_to_time(seconds) 以'hh:mm:ss'或hhmmss格式返回秒數轉成的time值(根據返回值所處上下文是字符串或數字) ~~~ mysql> select sec_to_time(2378);   -> '00:39:38' mysql> select sec_to_time(2378) + 0;   -> 3938 ~~~ ### 3.40 time_to_sec(time) 返回time值有多少秒 ~~~ mysql> select time_to_sec('22:23:00');   -> 80580 mysql> select time_to_sec('00:39:38');   -> 2378 ~~~ ## 4. 轉換函數 ### 4.1 cast 用法:cast(字段 as 數據類型) [當然是否可以成功轉換,還要看數據類型強制轉化時注意的問題] 實例: `select cast(a as unsigned) as b from cardserver where order by b desc;` ### 4.2 convert: 用法:convert(字段,數據類型) 實例: `select convert(a ,unsigned) as b from cardserver where order by b desc;` 本文參考http://blog.sina.com.cn/s/blog_4586764e0100h5ct.html
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看