MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL XOR Operator

In MySQL, XOR is used to check two operands, it returns NULL if either operand is NULL. For non-NULL operands, evaluates to 1 if an odd number of operands is nonzero, otherwise 0 is returned.

MySQL XOR OPERATOR Syntax

To check two operands, it returns NULL if either operand is NULL for non-NULL operands, evaluates to 1 if an odd number of operands is nonzero, otherwise 0 is returned, use the following syntax:

Syntax

SELECT a XOR b;  

Parameters:

a XOR b: Mathematically equal to (a AND (NOT b)) OR ((NOT a) and b).

MySQL XOR OPERATOR example

The following MySQL statement is used XOR operator to check two operand, both of the operands are true, so it returns FALSE.

Example

SELECT 1 XOR 1;

Note:

In the above example, both of the operands are true, so it returns FALSE

You can use MySQL Command Line Client to check two operands with XOR, it returns NULL if either operand is NULL. It will look like this: