SQL运算子
SQL运算符 SQL语句通常包含一些保留字或字符,用于执行比较和算术运算等操作。这些保留字或字符称为运算符。 …
SQL运算符
SQL语句通常包含一些保留字或字符,用于执行比较和算术运算等操作。这些保留字或字符称为运算符。
通常,SQL中有三种类型的运算符:
- SQL算术运算符
- SQL比较运算符
- SQL逻辑运算符
SQL算术运算符:
假设两个变量“ a”和“ b”。在此,“ a”的值为50,“ b”的值为100。
例:
| Operators | Descriptions | Examples |
|---|---|---|
| + | It is used to add containing values of both operands | a+b will give 150 |
| – | It subtracts right hand operand from left hand operand | a-b will give -50 |
| * | It multiply both operand’s values | a*b will give 5000 |
| / | It divides left hand operand by right hand operand | b/a will give 2 |
| % | It divides left hand operand by right hand operand and returns reminder | b%a will give 0 |
SQL比较运算符:
让我们采用两个分别为50和100的变量“ a”和“ b”。
| Operator | Description | Example |
|---|---|---|
| = | Examine both operands value that are equal or not,if yes condition become true. | (a=b) is not true |
| != | This is used to check the value of both operands equal or not,if not condition become true. | (a!=b) is true |
| < > | Examines the operand’s value equal or not, if values are not equal condition is true | (a<>b) is true |
| > | Examine the left operand value is greater than right Operand, if yes condition becomes true | (a>b) is not true |
| < | Examines the left operand value is less than right Operand, if yes condition becomes true | (a)> |
| >= | Examines that the value of left operand is greater than or equal to the value of right operand or not,if yes condition become true | (a>=b) is not true |
| <= | Examines that the value of left operand is less than or equal to the value of right operand or not, if yes condition becomes true | (a<=b) is true |
| !< | Examines that the left operand value is not less than the right operand value | (a!)> |
| !> | Examines that the value of left operand is not greater than the value of right operand | (a!>b) is true |
SQL逻辑运算符:
这是SQL中使用的逻辑运算符的列表。
| Operator | Description |
|---|---|
| ALL | this is used to compare a value to all values in another value set. |
| AND | this operator allows the existence of multiple conditions in an SQL statement. |
| ANY | this operator is used to compare the value in list according to the condition. |
| BETWEEN | this operator is used to search for values, that are within a set of values |
| IN | this operator is used to compare a value to that specified list value |
| NOT | the NOT operator reverse the meaning of any logical operator |
| OR | this operator is used to combine multiple conditions in SQL statements |
| EXISTS | the EXISTS operator is used to search for the presence of a row in a specified table |
| LIKE | this operator is used to compare a value to similar values using wildcard operator |
类别:MySQL、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。




还没有任何评论,赶紧来占个楼吧!