MySQL SQL中'AND'和'&&'的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4105658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The difference between 'AND' and '&&' in SQL
提问by Emanuil Rusev
Is there a difference in the way SQL interprets the logical operators AND
and &&
?
SQL 解释逻辑运算符的方式AND
和&&
?
采纳答案by Pekka
For mySQL: The manualis not saying it explicitly, but they are listed as identical:
对于 mySQL:手册没有明确说明,但它们被列为相同:
AND, &&
Logical AND. Evaluates to 1 if all operands are nonzero and not NULL, to 0 if one or more operands are 0, otherwise NULL is returned.
和, &&
逻辑与。如果所有操作数都非零且不为 NULL,则计算结果为 1,如果一个或多个操作数为 0,则计算结果为 0,否则返回 NULL。
The operator precedencepage also makes no distiction.
该运算符优先级页面也没什么distiction。
回答by onedaywhen
AND
is Standard SQL
AND
是标准 SQL
&&
is proprietary syntax
&&
是专有语法
回答by SilverSkin
According to this page http://msdn.microsoft.com/en-us/library/bb387129.aspxthey have the same functionality in SQL Server.
根据此页面http://msdn.microsoft.com/en-us/library/bb387129.aspx它们在 SQL Server 中具有相同的功能。
MySql has this to say on the subject http://dev.mysql.com/doc/refman/5.0/en/logical-operators.html
MySql 有这个关于这个主题的说法http://dev.mysql.com/doc/refman/5.0/en/logical-operators.html
回答by Lennert
If you're working with PostgreSQL, '&&' means overlap (have elements in common):
如果您正在使用 PostgreSQL,'&&' 表示重叠(具有共同的元素):
example: ARRAY[1,4,3] && ARRAY[2,1]
例子: ARRAY[1,4,3] && ARRAY[2,1]
https://www.postgresql.org/docs/9.1/static/functions-array.html
https://www.postgresql.org/docs/9.1/static/functions-array.html