Mysql內建函數

來源:互聯網
上載者:User

標籤:ted   unix時間   rom   curd   返回   max   空格   table   10個   

字串函數
select concat(‘hello‘,‘word‘,‘my‘) myname; // concat()  連結字元函數  輸出 hellowordmy  myname是別名select lcase(‘MYSQL‘);                    //lcase()   轉化成小寫     輸出 mysql select length(‘string‘)                    //length()  輸出字串的長度select ltrim(‘  strimg‘);                //ltrim()  去除左邊空格select rtrim(‘string  ‘);                //rtrim()  去除右邊空格select repeat(‘php,‘,3);                    //repeat() 重複次數  輸出  php,php,php,select replace(‘linux is very good‘,‘linux‘,‘php‘) ;  //replace()替換   輸出 php is very goodselect substr(‘linux is very good‘,1,5);    //substr(),mysql 的起始位置是1,輸出linuxselect space(10);                           //space();  產生10個空格
數學函數
select bin(192);                  //bin();  十進位轉二進位  ,輸出 11000000select celing(10.1);             //celing();  向上取整   輸出 11select floor(10.1);              //floor();  向下取整  輸出 10select max(col);               // max()  取最大值  彙總使用select min(col)                 //min()  取最小值  彙總使用select sqrt(4);                //sqrt()   開平方,輸出2select rand();                // rand() 隨機  select * from tablename order by rand()
日期函數
select curdate();                    //curdate();  當前日期  年月日select curtime();                    //curtime();  目前時間  時分秒select now();                         //now();     現在的日期和時間  年月日時分秒select unix_timestamp();                    //unix_timestamp();    返回當前unix時間戳記select week(‘2015-10-10‘);             //week();       返回當年的第幾周select year(‘2016-06-26‘);             //year();     輸出 2016 ,返回當前的年份select datediff(‘2016-10-10‘,‘2016-10-20‘);       // 輸出-10,返回兩個日期相差幾天

Mysql內建函數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.