PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
MySQL and Linux/Unix
MySQL and macOS
MySQL Partitioning
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL Restrictions and Limitations
Security in MySQL
MySQL and Solaris
Building MySQL from Source
Starting and Stopping MySQL
MySQL Tutorial
MySQL and Windows
MySQL NDB Cluster 7.5
In SQL, all logical operators evaluate toTRUE,FALSE, orNULL (UNKNOWN). In MySQL, these are implemented as 1 (TRUE), 0 (FALSE), andNULL. Most of this is common to different SQL database servers, although some servers may return any nonzero value forTRUE.
MySQL evaluates any nonzero, non-NULL value toTRUE. For example, the following statements all assess toTRUE:
mysql> SELECT 10 IS TRUE;-> 1mysql> SELECT -10 IS TRUE;-> 1mysql> SELECT 'string' IS NOT NULL;-> 1Logical NOT. Evaluates to
1if the operand is0, to0if the operand is nonzero, andNOT NULLreturnsNULL.mysql> SELECT NOT 10; -> 0mysql> SELECT NOT 0; -> 1mysql> SELECT NOT NULL; -> NULLmysql> SELECT ! (1+1); -> 0mysql> SELECT ! 1+1; -> 1The last example produces
1because the expression evaluates the same way as(!1)+1.Logical AND. Evaluates to
1if all operands are nonzero and notNULL, to0if one or more operands are0, otherwiseNULLis returned.mysql> SELECT 1 AND 1; -> 1mysql> SELECT 1 AND 0; -> 0mysql> SELECT 1 AND NULL; -> NULLmysql> SELECT 0 AND NULL; -> 0mysql> SELECT NULL AND 0; -> 0Logical OR. When both operands are non-
NULL, the result is1if any operand is nonzero, and0otherwise. With aNULLoperand, the result is1if the other operand is nonzero, andNULLotherwise. If both operands areNULL, the result isNULL.mysql> SELECT 1 OR 1; -> 1mysql> SELECT 1 OR 0; -> 1mysql> SELECT 0 OR 0; -> 0mysql> SELECT 0 OR NULL; -> NULLmysql> SELECT 1 OR NULL; -> 1NoteIf the
PIPES_AS_CONCATSQL mode is enabled,||signifies the SQL-standard string concatenation operator (likeCONCAT()).Logical XOR. Returns
NULLif either operand isNULL. For non-NULLoperands, evaluates to1if an odd number of operands is nonzero, otherwise0is returned.mysql> SELECT 1 XOR 1; -> 0mysql> SELECT 1 XOR 0; -> 1mysql> SELECT 1 XOR NULL; -> NULLmysql> SELECT 1 XOR 1 XOR 1; -> 1a XOR bis mathematically equal to(a AND (NOT b)) OR ((NOT a) and b).
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
MySQL and Linux/Unix
MySQL and macOS
MySQL Partitioning
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL Restrictions and Limitations
Security in MySQL
MySQL and Solaris
Building MySQL from Source
Starting and Stopping MySQL
MySQL Tutorial
MySQL and Windows
MySQL NDB Cluster 7.5