Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Sql Mysql-example Mysql XOR

Related Tutorials


 
 

Share on Google+Share on Google+

Mysql XOR

Advertisement
Mysql XOR returns you the output on the basis of condition specified in input. The output of the XOR is 0 when both the specified inputs are same.

Mysql XOR

     

Mysql XOR returns you the output on the basis of condition specified in input. The output of the XOR is 0 when both the specified inputs are same. The output is 1 when two input are different. To understand the Mysql XOR logical operation we provide you a demonstrative example below:

Query to use xor operation Truth Table

  A   B   Output
  0  0  0
  0  1  1
  1  0  1
  1  1  0

 

Query when the both input is '0' output is ' 0':

The below query is useful when you want the return output is 0. In this case we use 0and 0 as input and return you 0 as output.

mysql> SELECT 0 xor 0;
+---------+
| 0 xor 0 |
+---------+
| 0 |
+---------+
1 row in set (0.00 sec)

 Query one input is '0' and other is '1' then output is '1':

The below Query XOR return you '1' when 0 xor 1 or  0 xor1 (different types of input ).

mysql> SELECT 0 xor 1;
+---------+
| 0 xor 1 |
+---------+
| 1 |
+---------+
1 row in set (0.00 sec)

 

mysql> SELECT 1 xor 0;
+---------+
| 1 xor 0 |
+---------+
| 1 |
+---------+
1 row in set (0.00 sec)


Query both input is '1' then output is '0':

The Query return the output 0 when both the inputs are 1 or 0.

mysql> SELECT 1 xor 1;
+---------+
| 1 xor 1 |
+---------+
| 0 |
+---------+
1 row in set (0.00 sec)
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 20, 2009

Related Tutorials

Discuss: Mysql XOR  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com