我的MYSQL學習筆記(三)——運算子,mysql學習筆記

來源:互聯網
上載者:User

我的MYSQL學習筆記(三)——運算子,mysql學習筆記

1、安全等於運算子(<=>)

SELECT NULL <=> NULLUNION ALLSELECT NULL <=> 1union ALLSELECT 1<=>0UNION allSELECT NULL = NULL

注意此運算子和等於(=)的區別在於判斷兩個值都為空白的時候,執行結果如下:

2、LEAST運算子
作用:擷取多個參數值中的最小值
注意:不要混合資料類型使用

SELECT least(2,0),LEAST('a','b','c','d'),least(10,20,NULL)


混合使用出現錯誤

3、GREATEST運算子
作用:擷取多個參數中的最大值
注意:null值

4、REGEXP運算子
作用:正則式

SELECT 'ssky' REGEXP '^s','ssky' REGEXP 'y$' ,'ssky' REGEXP '.sky','ssky' REGEXP '[s]*';

相關文章

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.