Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

MySQL XOR Operator

by suresh

MySQL XOR Operator is one of the Logical Operator. In mathematics, x XOR y is equal to (x AND (NOT y)) OR ((NOT x) AND y). Generally, we use this MySQL XOR operator in the WHERE Clause to apply multiple filters on the rows or records returned by SELECT Statement.

This XOR operator returns the result as:

  • 1, if all operands are no nulls, and if an odd number of operands are non-zero, otherwise 0.
  • NULL, If either of the operands is NULL.

To explain the MySQL Logical XOR Operator in the WHERE Clause, we are going to use the below shown data.

MySQL XOR Operator 0

MySQL XOR Operator Command prompt

In this MySQL example, we pass Ones, Zeros, and Null values with a different combinations. This example helps you to understand the Truth table behind this XOR Operator.

-- MySQL XOR Operator Example

SELECT 1 XOR 1;

SELECT 1 XOR 0;

SELECT 0 XOR 0;

SELECT 1 XOR NULL;

SELECT 1 XOR 1 XOR 1 XOR 0;

SELECT 0 XOR NULL;

OUTPUT

MySQL XOR Operator Example 1

Logical XOR Operator Example

The XOR Operator test multiple conditions in WHERE Clause. If either one of the conditions in the WHERE Clause is TRUE, then the SELECT Statement displays the records.

-- MySQL XOR Operator Example
USE company;
SELECT CustID,
		First_Name, Last_Name,
        Education, Profession,
        Yearly_Income, Sales
FROM customers
WHERE Education = 'High School'
	XOR Yearly_Income > 90000;

OUTPUT

MySQL XOR Operator Example 2

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy