| Name | Description |
|---|---|
| AND, && | Logical AND 邏輯 AND |
| = | Assign a value (as part of a SET statement, or as part of the SET clause in an UPDATE statement)在 SET 語句中,可指派變數的值,如同「:=」 在其他地方,則當成比較運算子「等於」。 |
| := | Assign a value 指派變數的值。跟「=」不同,不會被當成比較運算子「等於」。 |
| BETWEEN ... AND ... | Check whether a value is within a range of values BETWEEN min AND max,「大於等於 min 且小於等於 max」 |
| BINARY | Cast a string to a binary string 「將字串轉成 binary字串」。 ysql> SELECT 'a' = 'A'; -> 1 mysql> SELECT BINARY 'a' = 'A'; -> 0 mysql> SELECT 'a' = 'a '; -> 1 mysql> SELECT BINARY 'a' = 'a '; -> 0 |
| & | Bitwise AND 位元運算子「AND」 |
| ~ | Invert bits 位元運算子「反轉」、「取補數」 |
| | | Bitwise OR 位元運算子「OR」 |
| ^ | Bitwise XOR 位元運算子「XOR」 |
| CASE | Case operator 「流程控制」 |
| DIV | Integer division 「整數除法,直接省略小數。跟 floor 在負數小數的結果不太一樣。 |
| / | Division operator 算術運算子,「除法」 |
| <=> | NULL-safe equal to operator 比較運算子,「判斷是不是 NULL」。在SET語句可當指派運算子,指派值。 |
| = | Equal operator 比較運算子,「等於」 |
| >= | Greater than or equal operator 比較運算子,「大於等於」 |
| > | Greater than operator 比較運算子,「大於」 |
| IS NOT NULL | NOT NULL value test 「判斷不是 NULL,回傳 1」 mysql> SELECT 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL; -> 1, 1, 0 |
| IS NOT | Test a value against a boolean IS NOT boolean_value,依照 boolean_value 來測試值,boolean_value可以是 TRUE、FALSE、UNKNOWN SELECT 1 IS NOT UNKNOWN, 0 IS NOT UNKNOWN, NULL IS NOT UNKNOWN; -> 1, 1, 0 |
| IS NULL | NULL value test 「判斷是 NULL,回傳 1」 mysql> SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL; -> 0, 0, 1 |
| IS | Test a value against a boolean IS boolean_value,依照 boolean_value 來測試值,boolean_value可以是 TRUE、FALSE、UNKNOWN SELECT 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN; -> 1, 1, 1 |
| << | Left shift 位元左移 |
| <= | Less than or equal operator 比較運算子,小於等於 |
| < | Less than operator 比較運算子,小於 |
| LIKE | Simple pattern matching 簡單樣式比對,expr LIKE pat pat:簡單的 SQL 正規表達式,可使用 % (匹配任何數目的字元,包括零字元)、_ (匹配單一字元) 匹配成功返回 1、失敗返回 0,expr、pat 任一個為 NULL,則返回 NULL |
| - | Minus operator 減法 |
| % or MOD | Modulo operator 取餘數 |
| NOT BETWEEN ... AND ... | Check whether a value is not within a range of values 跟 NOT (expr BETWEEN min AND max) 相同 |
| !=, <> | Not equal operator 比較運算子,不等於 |
| NOT LIKE | Negation of simple pattern matching |
| NOT REGEXP | Negation of REGEXP |
| NOT, ! | Negates value 邏輯運算子 NOT |
| ||, OR | Logical OR 邏輯運算子 OR |
| + | Addition operator 加法 |
| REGEXP | Pattern matching using regular expressions 使用正規表達式匹配。expr REGEXP pat |
| >> | Right shift 位元右移 |
| RLIKE | Synonym for REGEXP REGEXP 的同義詞 |
| SOUNDS LIKE | Compare sounds 與 SOUNDEX(expr1) = SOUNDEX(expr2) 相同 |
| * | Multiplication operator 乘法 |
| - | Change the sign of the argument 改變正負 |
| XOR | Logical XOR 邏輯運算子 XOR,a XOR b 猶如 (a AND (NOT b)) OR ((NOT a)和 b) |
參考:
http://dev.mysql.com/doc/refman/5.7/en/non-typed-operators.html
http://dev.mysql.com/doc/refman/5.1/zh/functions.html#non-typed-operators
沒有留言:
張貼留言