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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 17:38:16  来源:igfitidea点击:

The difference between 'AND' and '&&' in SQL

sqlmysqllogical-operators

提问by Emanuil Rusev

Is there a difference in the way SQL interprets the logical operators ANDand &&?

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

ANDis 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