mysql中幾個有用的函數,mysql有用函數

來源:互聯網
上載者:User

mysql中幾個有用的函數,mysql有用函數
1. FROM_UNIXTIME
作用:將MYSQL中以INT(11)儲存的時間以"YYYY-MM-DD"格式來顯示。例:

select mtime, from_unixtime(mtime) from topics limit 10;




2.  CONCAT(str1,str2,…) 作用:將str1, str2...串連為字串。如有任何一個參數為NULL ,則返回值為 NULL。例:
update video set playlink = concat(playlink, '&fr=abcd');
將表中所有的playlink上加一個fr參數
3. CONVERT(value, type);作用:將一個類型的值轉換為另一個類型

可以轉換的類型是有限制的。這個類型可以是以下值其中的一個:

    - 二進位,同帶binary首碼的效果 : BINARY        - 字元型,可帶參數 : CHAR()         - 日期 : DATE         - 時間: TIME         - 日期時間型 : DATETIME         - 浮點數 : DECIMAL          - 整數 : SIGNED         - 不帶正負號的整數 : UNSIGNED 例:假設有money欄位,為了不丟失其小數的精度,我們使用varchar記錄其值。但這時產生一個問題,如果要將這種欄位和數字比較大小怎麼辦呢?
select * from bill where convert(money, DECIMAL) > 100;

相關文章

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.